-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiThreadTest1.java
More file actions
43 lines (39 loc) · 980 Bytes
/
MultiThreadTest1.java
File metadata and controls
43 lines (39 loc) · 980 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
class MyThread extends Thread
{
public MyThread(String name)
{
super(name);
//setPriority(Thread.MAX_PRIORITY);
//setPriority(Thread.MIN_PRIORITY+2);
}
public void run()
{
int count=1;
while(true)
{
System.out.println(count++);
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
}
public class MultiThreadTest1 {
public static void main(String[] args)
{
MyThread t=new MyThread("My Thread1");
t.start();
t.interrupt();
/*System.out.println("ID "+t.getId());
System.out.println("Name "+t.getName());
System.out.println("Priority "+t.getPriority());
t.start();*/
System.out.println("State "+t.getState());
System.out.println("Alive "+t.isAlive());
}
}