A live daemon thread does not prevent an application from exiting. : Daemon Thread « Thread « Java Tutorial






class MyThread extends Thread {
  MyThread() {
    setDaemon(true);
  }

  public void run() {
    boolean isDaemon = isDaemon();
    System.out.println("isDaemon:" + isDaemon);
  }
}

public class Main {
  public static void main(String[] argv) throws Exception {
    Thread thread = new MyThread();
    thread.setDaemon(true);
    thread.start();
  }
}








10.7.Daemon Thread
10.7.1.Daemon and User Threads
10.7.2.A daemon thread.
10.7.3.An application exits when there are no non-daemon threads running.
10.7.4.A live daemon thread does not prevent an application from exiting.
10.7.5.A thread must be marked as a daemon thread before it is started.