-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiTherad_1.java
More file actions
56 lines (47 loc) · 1.01 KB
/
Copy pathMultiTherad_1.java
File metadata and controls
56 lines (47 loc) · 1.01 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
47
48
49
50
51
52
53
54
55
56
package s0904;
public class MultiTherad_1 {
public static void main(String[] args) {
MyTherad my = new MyTherad();
my.start();
MyTherad_1 my1 = new MyTherad_1();
my1.start();
// TODO Auto-generated method stub
for (int i = 0; i < 10; i++) {
System.out.print("* ");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
class MyTherad extends Thread {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.print(". ");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
class MyTherad_1 extends Thread {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.print("@ ");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}