守护线程
// 测试守护线程
// 上帝守护你
public class TestDaemon {
public static void main(String[] args) {
God god = new God();
You you = new You();
Thread thread = new Thread(god);
thread.setDaemon(true); // 默认是false表示用户线程,正常线程都是用户线程
thread.start(); // 上帝守护线程启动
new Thread(you).start(); //你 用户线程启动
}
}
// 上帝
class God implements Runnable{