public class TestJoin{ public static void main(String[] args){ Thread t = new Thread(new MyRunner()); t.start(); try{ t.join(); } catch(InterruptedException e){ e.printStackTrace(); } for(int i=0;i<10;i++){ System.out.println("Main:" + i); } } } class MyRunner implements Runnable{ public void run(){ for(int i=0;i<10;i++){ System.out.println("MyRunner:" + i); try{ Thread.sleep(1000); } catch(InterruptedException e){ e.printStackTrace(); } } } }