C# and .NET Interview questions: - What is Thread.Join () in threading?
- By Shiv Prasad Koirala in C#
- Nov 8th, 2012
There are two versions of Thread join-
- Thread.join (Integer) this returns a Boolean value.
The Thread.Join method is useful for determining if a thread has completed before starting another task. The Join method waits a specified amount of time for a thread to end. If the thread ends before the time-out, Join returns true; otherwise, it returns False. Once you call Join, the calling procedure stops and waits for the thread to signal that it is done.
Example you have "Thread1" and "Thread2" and while executing "Thread1" you call "Thread2.Join ()".So "Thread1" will wait until "Thread2" has completed its execution and the again invoke "Thread1".
Thread.Join (Integer) ensures that threads do not wait for a long time. If it exceeds a specific time, which is provided in integer the waiting thread will start.
See this video on Debug Threads.
Do not forget to watch below C#(CSharp) interview questions and answers series :-
Visit the link for more stuffs on C# and .NET Interview Questions
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more