Java守护程序线程


Java守护程序线程

class adminThread extends Thread {

   adminThread() {

      setDaemon(true);

   }

   public void run() {

      boolean d = isDaemon();

      System.out.println("daemon = " + d);

   }

}  

public class ThreadDemo {

   public static void main(String[] args) throws Exception {    

      Thread thread = new adminThread();

      System.out.println("thread = " + thread.currentThread());

      thread.setDaemon(true);

      thread.start();

   }

}