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

Discussion

Consider how long join(0) waits. Which statement is correct?

  • A.join(0) throws IllegalArgumentException, since a timeout must be positive.
  • B.join(0) waits indefinitely, exactly as the no-argument join() does.
  • C.join(0) returns immediately without waiting at all.
  • D.join(0) waits for one scheduler time slice.

Answer: B

The javadoc defines join() as behaving exactly like join(0), and states that a timeout of 0 means to wait forever. Treating zero as no wait is the natural reading and the wrong one, which is what makes it worth asking.

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

Post your comment

Please log in or register to post a comment.