Is there any bad effect if there is context switch between thread.start and thread.join?
if a thread finish executing before join, what will happen?
Is there any bad effect if there is context switch between thread.start and thread.join?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It really does depend a bit on what the child thread is doing for you, but generally if the main thread creates a child and then does more concurrent work while that child thread is away and the child finishes its execution first you will, at worst, have a race condition. This is when you have certain things that happen in you code that depend on the child thread doing work but not implementing controls to stop the main thread proceeding if it actually depends on that work being finished.
Ultimately a call to .join will result in an instantanious return as all the method does is wait until the child thread/s have finished execution. However, do watch out for accidental race conditions, they can be a right nightmare to debug!