-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThreadJoin.java
More file actions
34 lines (33 loc) · 784 Bytes
/
ThreadJoin.java
File metadata and controls
34 lines (33 loc) · 784 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
package multiThreading;
public class ThreadJoin {
public static void main(String[] args){
ThJoin thj = new ThJoin();
ThrJoin thrj = new ThrJoin();
System.out.println("in main: start");
thj.start();
thrj.start();
try{
thj.join(1500);
thrj.join();
}catch(Exception e) {
e.printStackTrace();
}
System.out.println("in main: end");
}
}
class ThJoin extends Thread{
@Override
public void run(){
for(int i = 0; i<5; i++){
System.out.println("ThJoin: "+i);
}
}
}
class ThrJoin extends Thread{
@Override
public void run() {
for (int i = 0; i < 5; i++) {
System.out.println("ThrJoin: " + i);
}
}
}