多线程---守护线程

package com.mokuiran.thread;
//测试守护线程
public class TestDaemon {
public static void main(String[] args) {
God god = new God();
You1 you1 = new You1();
Thread thread = new Thread(god);
thread.setDaemon(true);//默认是false表示用户线程,正常的线程都是用户线程
thread.start();//守护线程启动
new Thread(you1).start();
}
}
class God implements Runnable{
//最终输出结果:
//当“活着的36500次运行完毕,那么“保护者你”也会结束线程”

浙公网安备 33010602011771号