package org.hy.commons.lang.thread.example;


class Daemon  implements Runnable{

	public void run() {
		for (int i = 0; i < 200; i++) {
			System.out.println("Daemon -->" + i);
		}
	}
	
}
/**
 * åå°çº¿ç¨ï¼å¤äºåå°è¿è¡ï¼ä»»å¡æ¯ä¸ºå¶ä»çº¿ç¨æä¾æå¡ãä¹ç§°ä¸ºâå®æ¤çº¿ç¨ï¿½?æï¿½?ç²¾çµçº¿ç¨âï¿½?JVMçåå¾åæ¶å°±æ¯å¸åçåå°çº¿ç¨ï¿?ç¹ç¹ï¼è¥ï¿?ï¿½ï¿½çåå°çº¿ç¨é½æ­»äº¡ï¼åå°çº¿ç¨èªå¨æ­»äº¡ï¿½?
è®¾ç½®åå°çº¿ç¨ï¼Threadå¯¹è±¡setDaemon(true);
setDaemon(true)å¿é¡»å¨start()è°ç¨åï¿½?å¦ååºç°IllegalThreadStateExceptionå¼å¸¸ï¿?åå°çº¿ç¨åå»ºççº¿ç¨é»è®¤æ¯åå°çº¿ç¨;
å¤æ­æ¯å¦æ¯åå°çº¿ç¨ï¼ä½¿ç¨Threadå¯¹è±¡çisDaemon()æ¹æ³ï¿?å¹¶ä¸å½ä¸ä»å½åå»ºçº¿ç¨æ¯åå°çº¿ç¨æ¶ï¼æ°çº¿ç¨ææ¯åå°çº¿ç¨ï¿? * @author will
 *
 */
public class DaemonDemo {
	public static void main(String[] args) {
	/*	Thread cThread = Thread.currentThread();
		System.out.println(cThread.isAlive());
		
		//cThread.setDaemon(true);
		System.out.println(cThread.isDaemon());*/
		
		Thread t = new Thread(new Daemon());
		
		System.out.println(t.isDaemon());
		for (int i = 0; i < 10; i++) {
			
			System.out.println("main--" + i);
			if(i == 5){
				t.setDaemon(true);
				t.start();
			}
		}
	}
}