package socket;
public class DemonThreadDemo {
public static void main(String[] args) {
Thread rose = new Thread(){
public void run(){
for(int i=0;i<5;i++){
System.out.println("rose:let me go!");
try{
Thread.sleep(1000);
}catch(InterruptedException e)
{
}
}
System.out.println("rose:啊啊啊啊啊啊");
System.out.println("扑通");
}
};
Thread jack = new Thread(){
public void run(){
while(true){
System.out.println("jack:you jump");
try{
Thread.sleep(1000);
}catch(InterruptedException e)
{
}
}
}
};
rose.start();
//设置为守护线程
jack.setDaemon(true);
jack.start();
}
}