-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdemo6.java
More file actions
51 lines (42 loc) · 897 Bytes
/
demo6.java
File metadata and controls
51 lines (42 loc) · 897 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
45
46
47
48
49
50
51
/**
*
*/
package extendsthread;
/**
* @author M.NAVEEN
RANDOM CODER'S
*
*/
public class demo6 extends Thread
{
public demo6()
{
}
public void run()
{
for(int i=1;i<20;i++)
System.out.println(Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void main(String[] args)
{
demo6 t1=new demo6();
t1.start(); t1.setName(" Thread t1");
demo6 t2=new demo6();
t2.start(); t2.setName("Thread t2");
System.out.println("First -"+t1.isAlive());
System.out.println("second -"+t2.isAlive());
try{
t1.join();
t2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("First -"+t1.isAlive());
System.out.println("second -"+t2.isAlive());
}
}