Daemon线程?
public class ThreadA {public static void main(String[] args) {
System.out.println("ThreadA执行:");
Thread threadB = new Thread(new Runnable() {
public void run() {
try {
System.out.println("ThreadB开始:");
for (int i = 0; i < 5; i++ ) {
Thread.sleep(1000);
System.out.println("ThreadB执行..");
}
System.out.println("ThreadB即将结束..");
}
catch(InterruptedException e) {
e.printStackTrace();
}
}
}
);
threadB.setDaemon(true);//设置为Daemon线程
threadB.start();
System.out.println("ThreadA执行");
}
}
//
//C:\Users\Administrator\Desktop\classes>java ThreadA
//ThreadA执行
//ThreadA执行
//ThreadB开始
为什么不是ThreadA执行
ThreadB开始
ThreadA执行
求指导!!