package state;
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 You implements Runnable{
@Override
public void run() {
for (int i = 0; i < 36500; i++) {
System.out.println("你开心地活着");
}
System.out.println("=====goodbye world !");
}
}
class God implements Runnable{
@Override
public void run() {
while (true){
System.out.println("上帝守护着你");
}
}
}
标签:Thread,God,System,线程,new,public,守护,out
From: https://www.cnblogs.com/qt0312/p/17205406.html