ThreadGroup 类的 isDaemon() 方法测试该线程组是否为守护线程组。
用法
public final boolean isDaemon()
返回
如果此线程组是守护线程组,则此方法返回 true。否则,它将返回false。
示例
class NewThread extends Thread
{
NewThread(String threadname, ThreadGroup tg)
{
super(tg, threadname);
}
public void run()
{
for(int i = 0;i < 10;i++)
{
i++;
}
System.out.println(Thread.currentThread().getName() + " finished executing");
}
}
public class ThreadGroupIsDaemonExp
{
public static void main(String arg[]) throws InterruptedException,
SecurityException, Exception
{
// creating a threadGroup
ThreadGroup tg = new ThreadGroup("Parent thread");
// creating a thread
NewThread t1 = new NewThread("Thread-1", tg);
t1.start();
// returns false if this thread group is not a daemon thread group
System.out.println("Is " + tg.getName() + " a daemon threadGroup? " + tg.isDaemon());
}
}
输出:
Is Parent thread a daemon threadGroup? false Thread-1 finished executing
相关用法
- Java ThreadGroup isDaemon()用法及代码示例
- Java ThreadGroup isDestroyed()用法及代码示例
- Java ThreadGroup interrupt()用法及代码示例
- Java ThreadGroup enumerate()用法及代码示例
- Java ThreadGroup getMaxPriority()用法及代码示例
- Java ThreadGroup getParent()用法及代码示例
- Java ThreadGroup getName()用法及代码示例
- Java ThreadGroup parentOf()用法及代码示例
- Java ThreadGroup suspend()用法及代码示例
- Java ThreadGroup setDaemon()用法及代码示例
- Java ThreadGroup checkAccess()用法及代码示例
- Java ThreadGroup resume()用法及代码示例
- Java ThreadGroup toString()用法及代码示例
- Java ThreadGroup destroy()用法及代码示例
- Java ThreadGroup list()用法及代码示例
- Java ThreadGroup stop()用法及代码示例
- Java ThreadGroup activeCount()用法及代码示例
- Java ThreadGroup setMaxPriority()用法及代码示例
- Java ThreadGroup activeGroupCount()用法及代码示例
- Java Thread toString()用法及代码示例
注:本文由纯净天空筛选整理自 Java ThreadGroup isDaemon() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。