-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathThreadJoin.java
More file actions
30 lines (27 loc) · 769 Bytes
/
ThreadJoin.java
File metadata and controls
30 lines (27 loc) · 769 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
package example.oo.main;
public class ThreadJoin {
public static void main(String args[]) throws InterruptedException{
Thread t1= new Thread(){
public void run(){
for(byte b=0;b<100;b++){
System.out.println("THREAD 1: "+b);
}
}
};
Thread t2= new Thread(){
public void run(){
for(byte b=0;b<100;b++){
System.out.println("THREAD 2: "+b);
}
}
};
t1.start();
t2.start();
for(byte b=0;b<100;b++){
System.out.println("MAIN THREAD: "+b);
}
t1.join();
t2.join();
System.out.println("Last instruction");
}
}