Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which one of the following statements about which thread join() blocks is true?

  • A.join() makes the calling thread wait for the target thread to die.
  • B.join() makes the target thread wait for the calling thread to die.
  • C.join() merges the two threads so they share one stack.
  • D.join() returns immediately if the target thread has not been started.

Answer: A

join() waits for the thread it is invoked on to die, blocking the caller until then. The direction is the common confusion: t.join() suspends the current thread, not t. It is implemented as a loop of wait calls guarded by isAlive, with notifyAll issued as the thread terminates.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.