java 守护线程运行示例

import java.io.IOException;
public class ResponseUI extends Thread{

	private static volatile double d = 1;
	
	public ResponseUI(){
		super.setDaemon(true);
		start();
	}
	
	public void run(){
		while(true){
			d = d + (Math.E + Math.PI) / d;
		}
	}
	/**
	 * @param args
	 * @throws InterruptedException 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws InterruptedException, IOException {
		// TODO Auto-generated method stub
        new ResponseUI();
        Thread.sleep(300);
        System.in.read();
        System.out.println(d);
	}

}

 



已有 0 人发表留言,猛击->>这里<<-参与讨论


JavaEye推荐



posted @ 2010-06-04 13:28  zhwj184  阅读(172)  评论(0编辑  收藏  举报