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);
	}

}

 

你可能感兴趣的:(java,thread)