package com.li.thread_state;//测试守护线程//上帝守护你publicclassTestDaemonThread{
publicstaticvoidmain(String[] args){
God god =newGod();
You you =newYou();
Thread thread =newThread(god);
thread.setDaemon(true);//默认是false 表示是用户线程,正常的线程都是用户线程...
thread.start();//上帝守护线程启动newThread(you).start();// 你 用户线程启动...}}//上帝classGodimplementsRunnable{
@Overridepublicvoidrun(){
while(true){
System.out.println("我是上帝,我是永生的");}}}//你classYouimplementsRunnable{
@Overridepublicvoidrun(){
for(int i =0; i <36500; i++){
System.out.println("开心的活在这个世界上");}
System.out.println("--------goodbye,world----------");}}