forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVolatile.java
More file actions
executable file
·33 lines (31 loc) · 936 Bytes
/
Volatile.java
File metadata and controls
executable file
·33 lines (31 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* */ package extra.aboutthread;
/* */
/* */ import java.util.concurrent.TimeUnit;
/* */
/* */ public class Volatile {
/* */ boolean running = true;
/* */
/* */ void srv() {
/* 9 */ System.out.println("srv start");
/* 10 */ while (this.running);
/* */
/* */
/* 13 */ System.out.println("srv end");
/* */ }
/* */
/* */ public static void main(String[] args) {
/* 17 */ Volatile v = new Volatile();
/* 18 */ (new Thread(v::srv, "th1")).start();
/* */ try {
/* 20 */ TimeUnit.SECONDS.sleep(3L);
/* */ }
/* 22 */ catch (InterruptedException e) {
/* 23 */ e.printStackTrace();
/* */ }
/* 25 */ v.running = false;
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/extra/aboutthread/Volatile.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/