|
Re: join() ???
|
Posted: Jan 7, 2004 8:47 PM
|
|
Suppose t is a thread. When you write
t.join();
then this statement will execute in some thread. Let us call that tread as t1. After the above statement is executed, t1 thread will block until thread t dies.
This kind of statement is used when you do some kind of processing in multiple threads. But the processing at some stage cannot be started untill processing in one thread is done. For example, suppose you have some complex time taking processing to do and you have three parts of processing. The third part can be started only when first two parts are done. So, in one thread yo can write code as:
t1.start() ; // Start first part t2.start() ; // start second part
// Let us wait for both threads to finish both parts t1.join(); t2.join();
// Here both pars are done. Assuming your threads t1, t2 //terminated after processing
// Here you can start third stage of your processing
|
|