-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJoin.java
More file actions
35 lines (35 loc) · 1 KB
/
Join.java
File metadata and controls
35 lines (35 loc) · 1 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
public class Th_Cont_Mech implements Runnable {
@Override
public void run() {
for(int i=1;i<=10;i++){
if (i != 6) {
System.out.println(i);
}
else{
try {
Thread.sleep(5000);
System.out.println(i);
} catch (InterruptedException e) {
System.out.println("Exception Caught");
}
}
}
}
}
class Testtt{
public static void main(String[] args) {
Th_Cont_Mech obj = new Th_Cont_Mech();
Thread obj1 = new Thread(obj);
Thread obj2 = new Thread(obj);
Thread obj3 = new Thread(obj);
obj1.start();
try {
obj1.join();
obj2.start();
obj2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
obj3.start();
}
}