How do I have one thread wait for another thread to finish before continuing?
Created Feb 18, 2000
John Zukowski
You can wait for a thread to finish by calling its join() method. For instance, in the following code, the current thread will wait until thread2 finishes before printing Done.
thread2.start();
// do more stuff here
thread2.join();
System.out.println("Done");