-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
32 lines (27 loc) · 1.07 KB
/
Copy pathApp.java
File metadata and controls
32 lines (27 loc) · 1.07 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
package io.github.hooj0.thread.group;
import io.github.hooj0.BasedTests;
/**
* 应用程序
*
* @author hoojo
* @version 1.0
* @date Nov 6, 2010 6:57:22 PM
*/
public class App extends BasedTests {
public static void main(String[] args) {
//获得主线程所在的线程组,这是所有线程默认的线程组
ThreadGroup mainGroup = Thread.currentThread().getThreadGroup();
out("主线程的名称:" + mainGroup.getName());
out("是否后台线程组:" + mainGroup.isDaemon());
new CustomGroupThread("主线程组的线程").start();
ThreadGroup tg = new ThreadGroup("新线程组-后台线程组");
tg.setDaemon(true);
out("新线程组-后台线程组 是否是后台线程" + tg.isDaemon());
new CustomGroupThread(tg, "新线程组-后台线程组 的线程A").start();
new CustomGroupThread(tg, "新线程组-后台线程组 的线程B").start();
}
}
/*
* uncaughtException(Thread t, Throwable e)
* 该方法可以处理该线程组内的线程所抛出的未处理的异常
*/