This is from a question in Enthuware's
SCJP 6 exam suite.
It says that a
thread which is blocked because it's trying to enter synchronized block will return to runnable when notify() or notifyAll() are called.
I don't understand that, I thought a blocked thread returns to runnable when the lock is released, but didn't know that notify() or notifyAll() were necessary, and I only thought those methods were effective unless the thread had issued a wait() call.
This brings another question: If a thread tries to acquire a lock but the lock is not available, does that put the thread in the blocked state immediately, and if so, how does the thread come back to runnable? Does the JVM notify the thread that the lock has been released?
Thanks in advance for your answers.
Edit: Does the SCJP 6 exam even cover blocked threads? I seem to remember from the K&B book something about that not being covered.
[ December 18, 2008: Message edited by: Ruben Soto ]
[ December 18, 2008: Message edited by: Ruben Soto ]