How do I have one thread wait for another thread to finish before continuing?
Created May 4, 2012
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");