线程分为用户线程(正常都是用户线程)和守护线程。
虚拟机要等用户线程,不等守护线程。
setDaemon是boolean值,默认是false
public class TestThreadDaemon {
public static void main(String[] args) {
Story story = new Story();
Thread thread1 = new Thread(story);
thread1.setDaemon(true);
thread1.start();
new Thread(new Love()).start();
}
}
class Love implements Runnable{
浙公网安备 33010602011771号