Why didn't the join() on line#18 caused the currently executing thread to join itself.?
swaraj gupta wrote:Hello Deepak, this is what I have discussed few days back..this
And came to the conclusion that using only join() causes currently executing thread to join itself, until it finishes its own execution. Now what do you say..?
Deepak Bala wrote:
swaraj gupta wrote:Hello Deepak, this is what I have discussed few days back..this
And came to the conclusion that using only join() causes currently executing thread to join itself, until it finishes its own execution. Now what do you say..?
I would say Ankit's comment here, reflects my own -> https://coderanch.com/forums/posts/list/517455#2344028
love demgracy, knowledge demogracy, open source and Java - OCPJP 76%
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:In which thread is the show method called?? I believe its the main thread not the new thread created in the code, thus main is waiting for the other thread to complete...
love demgracy, knowledge demogracy, open source and Java - OCPJP 76%
swaraj gupta wrote:Hello Imad, why didn't main thread stop after executing the join() method, thats my doubt actually....
swaraj gupta wrote:Please let me know, what exactly only "join()" means when it is not invoked by a thread instance.
The description given in (KS && BB) and (khalid A.Mughal) is not turning to be insufficient for me.
Imad Aydarooos wrote:Thanks for the enlightment Ankit
but the main thread is started by the JVM and I don't think its a Starter
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Imad Aydarooos wrote:Dear Swaraj, below your code after inserting some SOP statments, as you see from the output there is actually 2 threads, the main() thread and Thread-0. Thread-0 will join and stuck there and the main thread will complete the job.
love demgracy, knowledge demogracy, open source and Java - OCPJP 76%
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I believe its the main thread not the new thread created in the code, thus main is waiting for the other thread to complete...
what exactly only "join()" means when it is not invoked by a thread instance.
Dharmesh Tyagi wrote:mine might be a bad question but don't we invoke join() on some object ?
over here how is it able to know that with which thread it has to join with ..