-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJoinTest.java
More file actions
44 lines (36 loc) · 745 Bytes
/
Copy pathJoinTest.java
File metadata and controls
44 lines (36 loc) · 745 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
package java_base;
class T extends Thread{
Thread t;
public T(String name, Thread t) {
// TODO Auto-generated constructor stub
setName(name);
this.t = t;
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
if(t != null)
{
t.join();
}
System.out.println(getName() + "start");
Thread.sleep(1000);
System.out.println(getName() + "end");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public class JoinTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
T p3 = new T("C", null);
T p2 = new T("B", p3);
T p1 = new T("A", p2);
p1.start();
p2.start();
p3.start();
}
}