Thread thread = new Thread("New Thread")
{
public void run(){
//instructions A,B and C
}
};
thread.start();
//instructions D, E
I wonder why D and E do not run after termination of instructions A, B and C.
How do I make D and E run after instructions A, B and C finish?
1. If you want D and E to run after the completion of the A,B and C, then you must use
join().2. When join() is called on a thread, then it waits for that thread to die(ie to finish its run() method), then execute the line after the join().
3. Its better to use
CountDownLatch from java.util.concurrentpackage.