What will or won't cause a thread to block (a question from a test)

Posted by fingerprint211b on Stack Overflow See other posts from Stack Overflow or by fingerprint211b
Published on 2010-03-20T13:05:53Z Indexed on 2010/03/20 13:11 UTC
Read the original article Hit count: 103

Filed under:
|

I've had a test, and there was a question I lost some points on, because I wasn't able to answer it :

Which of the following is NOT a condition which can cause a thread to block :

  • Calling an objects's wait() method
  • Waiting for an I/O operation
  • Calling sleep()
  • Calling yield()
  • Calling join()

As far as I know, all of these are blocking calls :

  • wait() returns when an something calls notify(), blocks until then
  • If the thread is WAITING for an I/O operation then it's obviously blocked
  • sleep(), obviously, blocks until the time runs out, or something wakes up the thread
  • yield() "cancels the rest of the thread's timeslice" (lacking a better term), and returns only when the thread is active again
  • join() blocks until the thread it's waiting for terminates.

Am I missing something here?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading