-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
45 lines (28 loc) · 1.01 KB
/
Test.java
File metadata and controls
45 lines (28 loc) · 1.01 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
package com.interview.threads;
class ThreadTest extends Thread{
@Override
public void run() {
super.run();
for (int i = 0; i < 5; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Hi i am runing !");
}
}
public synchronized void testSync() {
}
}
public class Test {
public static void main(String[] args) {
ThreadTest test = new ThreadTest();
System.out.println("Id is : "+test.getId()+" Thread name is :"+test.getName()+" Priority is : "+test.getPriority()+" State is :"+test.getState());
System.out.println("I am main thread ... !");
System.out.println("Id is : "+test.getId()+" Thread name is :"+test.getName()+" Priority is : "+test.getPriority()+" State is :"+test.getState());
test.start();
System.out.println("Id is : "+test.getId()+" Thread name is :"+test.getName()+" Priority is : "+test.getPriority()+" State is :"+test.getState());
}
}