package theardtest; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Wei.Liu */ public class Main extends Thread { /** * @param args the command line arguments */ public volatile boolean finished = false; public void run(){ int i=0; while(!finished){ System.out.println(i); i++; } } public static void main(String[] args) { // TODO code application logic here Main temp = new Main(); temp.start(); try { Thread.sleep(10000);// } catch (InterruptedException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } temp.finished=true; } |