When you call Thread.Join() , it blocks the calling thread until the thread having the Join method terminates. If it is interrupted or successfully completed, the connection () that follows will not block the calling thread. This allows you to have 10 worker threads and one main thread that should be executed after all 10 threads have completed. That way you can call Join () on the first thread. This call blocks the main thread until the first worker thread completes. After that, you can call Join () in the second thread, and so on, until you get to thread # 10. When you call Join () on it, and the main thread resumes, you can be sure that all 10 threads are completed, and the main thread can resume its work.
For example:
Thread workers[] = new Thread[10]; //*** create and start threads *** foreach(Thread worker in workers) { worker.Join(); } //All threads are completed, now this operation can continue...
On the other hand, Thread.ThreadState returns the status of the thread (Aborted, Running, ...) without affecting the calling thread state (not like Join, which puts the calling thread in WaitSleepJoin state). So this should be used only if you want to check what happens to the stream so that you can take a specific action or want to implement your own Join mechanism, etc.
Cipi
source share