-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreadTest.java
44 lines (39 loc) · 1002 Bytes
/
ThreadTest.java
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
class Mythread extends Thread
{
public Mythread(String name)
{
super(name);
setPriority(Thread.MAX_PRIORITY);
}
public void run()
{
int count =1;
while(true)
{
System.out.println(count);
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println(e);
}
count++;
}
}
}
public class ThreadTest
{
public static void main(String args[]) throws Exception
{
Mythread t=new Mythread(" My Thread 1");
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());
t.interrupt();
}
}