We can use join() method for this purpose. On calling join() method,
current thread waits for the child thread to which it joins to finish.
Sample code is as follows:
Thread myThread = new Thread(new Runnable() {
public void run() {
}
});
myThread.start();
// Join on myThread
myThread.join()