[Logo]
Forums Register Login
join()


output that comes it hard to understand.....

i am trying to understand the join() method in which i want the 3rd thread and 2nd thread to join the first thread.....can anyone explain me this?

thanks
 
i want the 3rd thread and 2nd thread to join the first thread.

Right now your main thread will wait for the 1st thread to join i.e. the run method completes.

If you want the 3rd and 2nd thread to join the 1st thread, then you'll have to call join on t2 and t3 in the 1st thread not in the main method. You need to understand the use of join method properly. When you call join on an instance of a Thread class, the method call returns i.e. the method call ends when the thread on which the join method was called ends i.e. the run method completes. So if in thread A1 you call join on thread A2, then A1 will continue execution when A2 thread completes...
 
i want the 3rd thread and 2nd thread to join the first thread.


Joining the second and third thread means the first thread would start its execution only then the joining threads would have completed the execution. I have tweaked your code a bit for the same.

Kindly have a look and let me know whether it fulfills your need.

Thanks Ankit and Salil.....Salil your code cleared everything
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 11, 2017 10:27:03.