-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1114.按序打印.java
50 lines (33 loc) · 976 Bytes
/
1114.按序打印.java
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
48
49
/*
* @lc app=leetcode.cn id=1114 lang=java
*
* [1114]
*/
// @lc code=start
class Foo {
volatile int num=0;
public Foo() {
}
public void first(Runnable printFirst) throws InterruptedException {
while(num!=0){
}
// printFirst.run() outputs "first". Do not change or remove this line.
printFirst.run();
num++;
}
public void second(Runnable printSecond) throws InterruptedException {
while(num!=1){
}
// printSecond.run() outputs "second". Do not change or remove this line.
printSecond.run();
num++;
}
public void third(Runnable printThird) throws InterruptedException {
while(num!=2){
}
// printThird.run() outputs "third". Do not change or remove this line.
printThird.run();
num=0;
}
}
// @lc code=end