-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyThread.java
More file actions
54 lines (47 loc) · 1020 Bytes
/
Copy pathMyThread.java
File metadata and controls
54 lines (47 loc) · 1020 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package multithreading;
import java.lang.Thread;
class A extends Thread {
public void run() {
int i = 1;
while (i < 10) {
System.out.println("Running thread A " + i);
i++;
}
}
}
class B implements Runnable {
@Override
public void run() {
int i = 1;
while (i < 10) {
System.out.println("Running thread B " + i);
i++;
}
}
}
class C extends Thread {
public void run() {
int i = 1;
while (i < 10) {
System.out.println("Running thread C " + i);
i++;
}
}
}
public class MyThread {
public static void main(String[] args) {
A a = new A();
C c = new C();
B b = new B();
Thread t = new Thread(b);
// start the threads..
a.start();
try {
c.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
c.start();
t.start();
}
}