-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThreadPriority.java
More file actions
34 lines (30 loc) · 995 Bytes
/
ThreadPriority.java
File metadata and controls
34 lines (30 loc) · 995 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
package CreateThead;
public class ThreadPriority {
public static void main(String[] args) {
System.out.println("Main Thread start");
Thread t = new Thread(() -> {
System.out.println("Thread start"+Thread.currentThread().getName());
Thread t2 = new Thread(() -> {
System.out.println("Thread start"+Thread.currentThread().getName());
execute();
}, "Thread 2");
// t2.setDaemon(true);
t2.start();
execute();
}, "Thread 1");
t.setDaemon(true);
t.start();
// t.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Main Thread end");
}
public static void execute(){
for(int i = 0;i<10;i++){
System.out.println(i+Thread.currentThread().getName());
}
}
}