-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
31 lines (27 loc) · 960 Bytes
/
test.java
File metadata and controls
31 lines (27 loc) · 960 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
class CoffeeMachine implements Runnable {
private String machineId;
private String coffeeType;
public CoffeeMachine(String machineId, String coffeeType) {
this.machineId = machineId;
this.coffeeType = coffeeType;
}
@Override
public void run() {
for (int i = 0; i < 4; i++) {
System.out.println("Currently the coffee Machine " + machineId + " is brewing " + coffeeType);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
Thread machine1 = new Thread(new CoffeeMachine("CM1", "Espresso"));
Thread machine2 = new Thread(new CoffeeMachine("CM2", "Latte"));
Thread machine3 = new Thread(new CoffeeMachine("CM3", "Cappuccino"));
machine1.start();
machine2.start();
machine3.start();
}
}