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推荐