-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreeThreads.java
61 lines (55 loc) · 952 Bytes
/
ThreeThreads.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class H extends Thread{
int i = 0;
public void run() {
while(true) {
i++;
System.out.println(i%12);
try {
Thread.sleep(3600000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
class M extends Thread{
int i = 0;
public void run() {
while(true) {
i++;
System.out.println(i%60);
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
class S extends Thread{
int i = 0;
public void run() {
while(true) {
i++;
System.out.println(i%60);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public class ThreeThreads {
public static void main(String[] args) {
H h = new H();
M m = new M();
S s = new S();
h.start();
m.start();
s.start();
}
}