-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
46 lines (33 loc) · 1.04 KB
/
Customer.java
File metadata and controls
46 lines (33 loc) · 1.04 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
package barber;
public class Customer extends Thread{
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public void run() {
//System.out.println(this.getName()+" is new " +Solution.p());
try {
Solution.mutex.acquire();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(this.getName()+" is coming in barber " +Solution.p());
if(Solution.emptyChairs.get()> 0) {
Solution.emptyChairs.decrementAndGet();
Solution.custom.release();
Solution.mutex.release();
System.out.println(this.getName()+" is sit down " +Solution.p());
try {
Solution.barber.acquire();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
Solution.name = this.getName();
System.out.println(this.getName()+" is cuting " +Solution.p());
}else {
Solution.mutex.release();
System.out.println(this.getName()+" go for no seat "+Solution.p());
}
}
}