-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarber.java
More file actions
41 lines (30 loc) · 752 Bytes
/
Barber.java
File metadata and controls
41 lines (30 loc) · 752 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
34
35
36
37
38
39
40
41
package barber;
public class Barber extends Thread{
private boolean wakeUp = false;
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public void run() {
while(true) {
try {
Solution.custom.acquire();
Solution.mutex.acquire();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Solution.emptyChairs.incrementAndGet();
Solution.barber.release();
Solution.mutex.release();
try {
this.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(Solution.name+" is finish " +Solution.p());
}
}
public void cut() {
}
}