-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDaemonThreadMain.java
More file actions
30 lines (24 loc) · 1019 Bytes
/
Copy pathDaemonThreadMain.java
File metadata and controls
30 lines (24 loc) · 1019 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
package thread.start;
public class DaemonThreadMain {
public static void main(String[] args) {
System.out.println(Thread.currentThread().getName() + " : main() start");
DaemonThread daemonThread = new DaemonThread();
System.out.println(daemonThread.currentThread().getName() + " : start() 호출 전");
daemonThread.setDaemon(true);
daemonThread.start();
System.out.println(daemonThread.currentThread().getName() + " : start() 호출 후");
System.out.println(Thread.currentThread().getName() + " : main() end");
}
static class DaemonThread extends Thread {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + " : start" );
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println(Thread.currentThread().getName() + " : end" );
}
}
}