Page 1 of 1

About Question enthuware.ocpjp.v7.2.1239 :

Posted: Tue Aug 05, 2014 3:02 am
by sasha32003
Good day!
Could you explain the following. English is my second language, so there could be misunderstanding.

I wonder about this sentence (10 - Threads, question Number 14):
"The concept is when a thread calls join() on another thread, the calling thread waits till the other thread dies."

Lets say we have main thread and one created in main, we call it t.
So it means: When thread call join() i.e. t calls join() - t.join() - on another thread i.e - main, the calling thread, which is t waits till the other thread i.e. - main thread dies.

But its actually other way around. When u say: t.join() inside main -> you saying: "Join me (the current thread-MAIN) to the end of t, so that t
must finish before I (the current thread-MAIN) can run again."

Please correct me if I am wrong, or just misunderstood.

Re: About Question enthuware.ocpjp.v7.2.1239 :

Posted: Tue Aug 05, 2014 3:17 am
by admin
No, you misunderstood.
If the main thread executes the line t.join(), the main thread will wait until thread t dies.
So it means: When thread call join() i.e. t calls join() - t.join() -
That is not correct. You are misreading the call t.join().
t.join() doesn't mean t calls join. It means join() is called on the object referred to by t.
Just by looking at t.join(), you cannot tell who is calling t.join(). You have to look at the whole code to see which thread is calling t.join().

Re: About Question enthuware.ocpjp.v7.2.1239 :

Posted: Tue Aug 05, 2014 3:28 am
by sasha32003
admin wrote:No, you misunderstood.
If the main thread executes the line t.join(), the main thread will wait until thread t dies.
So it means: When thread call join() i.e. t calls join() - t.join() -
That is not correct. You are misreading the call t.join().
t.join() doesn't mean t calls join. It means join() is called on the object referred to by t.
Just by looking at t.join(), you cannot tell who is calling t.join(). You have to look at the whole code to see which thread is calling t.join().

Ok, got it now. Thank you. Difficult ... misreading the question often gives me a low result.