Back To Java Multithreading Index
//program to demonstrate thread join Method public class MyThread1 extends Thread { public void run() { System.out.println("r1 "); try { Thread.sleep(500); }catch(InterruptedException ie){ } System.out.println("r2 "); } public static void main(String[] args) { MyThread1 t1=new MyThread1(); MyThread1 t2=new MyThread1(); t1.start(); try{ t1.join(); //Waiting for t1 to finish }catch(InterruptedException ie){} t2.start(); } }