-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathHalvahShop.java
More file actions
37 lines (31 loc) · 852 Bytes
/
Copy pathHalvahShop.java
File metadata and controls
37 lines (31 loc) · 852 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
package ds.shop;
import ds.silo.Silo;
public class HalvahShop extends Thread {
private final Silo oilSilo;
private final Silo flourSilo;
private final Silo sugarSilo;
public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
super("Halvah");
this.flourSilo = fsilo;
this.oilSilo = osilo;
this.sugarSilo = ssilo;
}
public void run() {
while (true) {
try {
sleep((int) (Math.random() * 100));
} catch (InterruptedException e) {
e.printStackTrace();
}
//2 unit oil
oilSilo.get();
oilSilo.get();
//1 unit flour
flourSilo.get();
//3 unit sugar
sugarSilo.get();
sugarSilo.get();
sugarSilo.get();
}
}
}