-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiThreading5.java
More file actions
49 lines (38 loc) · 1.22 KB
/
MultiThreading5.java
File metadata and controls
49 lines (38 loc) · 1.22 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Created by Admin on 14-04-2017.
*/
public class MultiThreading5{
public static void main(String[] args){
MyThread thread1=new MyThread();
MyThread thread2=new MyThread();
MyThread thread3=new MyThread();
System.out.println("thread1 is alive "+thread1.t.isAlive());
System.out.println("thread2 is alive "+thread2.t.isAlive());
System.out.println("thread3 is alive "+thread3.t.isAlive());
try {
thread1.t.join();
thread2.t.join();
thread3.t.join();
}catch (Exception e){
}
System.out.println("thread1 is alive "+thread1.t.isAlive());
System.out.println("thread2 is alive "+thread2.t.isAlive());
System.out.println("thread3 is alive "+thread3.t.isAlive());
}
public static class MyThread implements Runnable{
Thread t;
MyThread(){
t=new Thread(this);
t.start();
}
@Override
public void run() {
for(int i=0;i<100;i++){
try{
Thread.sleep(10);
}catch (Exception e){
}
}
}
}
}