什么是Java中的守护程序线程?
Java中的守护程序线程是在后台连续执行的线程。您可以使用setDaemon()方法设置线程守护程序。
示例
class adminThread extends Thread {
adminThread() {
setDaemon(true);
}
public void run() {
boolean d = isDaemon();
System.out.println("daemon = " + d);
}
}
public class ThreadDemo {
public static void main(String[] args) throws Exception {
Thread thread = new adminThread();
System.out.println("thread = " + thread.currentThread());
thread.setDaemon(true);
thread.start();
}
}输出结果
thread = Thread[main, 5, main]
热门推荐
10 小侄过生日祝福语简短
11 小店营业的祝福语简短
12 担任老师的祝福语简短
13 饮料吧台祝福语简短大气
14 公司新春搞笑祝福语简短
15 高情商敬酒祝福语简短
16 婚礼祝福语新郎妹妹简短
17 教师答辩通过祝福语简短
18 生女孩红包简短祝福语