?? threadgrouptest.java
字號:
/**
* Description:
* <br/>Copyright (C), 2008-2010, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
class TestThread extends Thread
{
//提供指定線程名的構(gòu)造器
public TestThread(String name)
{
super(name);
}
//提供指定線程名、線程組的構(gòu)造器
public TestThread(ThreadGroup group , String name)
{
super(group, name);
}
public void run()
{
for (int i = 0; i < 20 ; i++ )
{
System.out.println(getName() + " 線程的i變量" + i);
}
}
}
public class ThreadGroupTest
{
public static void main(String[] args)
{
//獲取主線程所在的線程組,這是所有線程默認(rèn)的線程組
ThreadGroup mainGroup = Thread.currentThread().getThreadGroup();
System.out.println("主線程組的名字:"
+ mainGroup.getName());
System.out.println("主線程組是否是后臺線程組:"
+ mainGroup.isDaemon());
new TestThread("主線程組的線程").start();
ThreadGroup tg = new ThreadGroup("新線程組");
tg.setDaemon(true);
System.out.println("tg線程組是否是后臺線程組:"
+ tg.isDaemon());
TestThread tt = new TestThread(tg , "tg組的線程甲");
tt.start();
new TestThread(tg , "tg組的線程乙").start();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -