What will or won't cause a thread to block (a question from a test)
- by fingerprint211b
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?