-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattle.java
More file actions
40 lines (33 loc) · 812 Bytes
/
Battle.java
File metadata and controls
40 lines (33 loc) · 812 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
class EggVoice extends Thread {
public void run() {
for(int i = 0; i < 5; i++) {
try {
sleep(1000);
} catch(InterruptedException e) {}
System.out.println("egg!");
}
}
}
class ChickenVoice extends Thread {
public void run() {
for(int i = 0; i < 5; i++) {
try {
sleep(1000);
} catch(InterruptedException e) {}
System.out.println("chicken!");
}
}
}
class Battle {
public static void main(String ... args) {
EggVoice mAnotherOpinion = new EggVoice();
ChickenVoice mAnotherOpinion2 = new ChickenVoice();
System.out.println("Let's the battle begin...");
mAnotherOpinion.start();
mAnotherOpinion2.start();
try {
Thread.sleep(6000);
} catch(InterruptedException e) {}
System.out.println("The end!");
}
}