public class DaemonTest {
public static void main(String[] args) {
Thread thread = new Thread(new Runnable() {
public void run() {
while(true) {
System.out.print("T");
}
}
});
thread.setDaemon(true);
thread.start();
}
}
如果没有thread.setDaemon(true); ,则虽然main线程结束过后,thread这个线程仍然在运行