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.
About Question enthuware.ocpjp.v7.2.1239 :
Moderator: admin
-
- Posts: 12
- Joined: Tue Aug 05, 2014 2:47 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1239 :
No, you misunderstood.
If the main thread executes the line t.join(), the main thread will wait until thread t dies.
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().
If the main thread executes the line t.join(), the main thread will wait until thread t dies.
That is not correct. You are misreading the call t.join().So it means: When thread call join() i.e. t calls join() - 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().
-
- Posts: 12
- Joined: Tue Aug 05, 2014 2:47 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1239 :
admin wrote:No, you misunderstood.
If the main thread executes the line t.join(), the main thread will wait until thread t dies.That is not correct. You are misreading the call t.join().So it means: When thread call join() i.e. t calls join() - 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.
Who is online
Users browsing this forum: Google [Bot] and 7 guests