public class ThreadTest { public static void main(String[] args) { MyThread myThread = new MyThread(); myThread.start(); try { myThread.join(); //主要是这个代码 } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("现在到我了..."); } private static class MyThread extends Thread{ public void run(){ int i = 50000; System.out.println("先执行..."); while(i>0){ i--; } System.out.println("执行完成!"); } } }
**主要是Thread.join()代码的问题