Assume,I have thread T1, T2 and T3, how will I ensure that thread T2 run after T1 and thread T3 run after T2?
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.
The solution to your problem is probably “don’t use multiple threads.” If you want to ensure that action 2 executes after action 1, and action 3 executes after action 2, with no interleaving, then the solution is to execute action 1, then execute action 2, then execute action 3. Threads are useful as a mechanism for parallelism, and by trying to make sure that the actions run in a specific order you are explicitly disallowing parallelism. Don’t try to use a mechanism to do the exact opposite of the thing it was designed to do.