forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisOrder.java
More file actions
executable file
·47 lines (45 loc) · 1.43 KB
/
DisOrder.java
File metadata and controls
executable file
·47 lines (45 loc) · 1.43 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* */ package extra.aboutthread;
/* */
/* */ public class DisOrder {
/* 4 */ private static int x = 0, y = 0;
/* 5 */ private static int a = 0, b = 0;
/* */
/* */ public static void main(String[] args) throws InterruptedException {
/* 8 */ int i = 0;
/* */ while (true) {
/* 10 */ i++;
/* 11 */ x = 0; y = 0;
/* 12 */ a = 0; b = 0;
/* 13 */ Thread one = new Thread(new Runnable()
/* */ {
/* */ public void run() {
/* 16 */ DisOrder.a = 1;
/* 17 */ DisOrder.x = DisOrder.b;
/* */ }
/* */ });
/* 20 */ Thread other = new Thread(new Runnable()
/* */ {
/* */ public void run() {
/* 23 */ DisOrder.b = 1;
/* 24 */ DisOrder.y = DisOrder.a;
/* */ }
/* */ });
/* */
/* */
/* 29 */ one.start();
/* 30 */ other.start();
/* 31 */ one.join();
/* 32 */ other.join();
/* */
/* 34 */ String result = "第" + i + "次 (" + x + "," + y + ")";
/* 35 */ if (x == 0 && y == 0) {
/* 36 */ System.out.println(result);
/* */ return;
/* */ }
/* */ }
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/extra/aboutthread/DisOrder.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/