Page 1 of 1

About Question enthuware.ocpjp.v7.2.1467 :

Posted: Wed Aug 10, 2016 6:50 am
by insider
I answered "calling someObject.wait()" (no doubt about this) and "someObj.notify()" (which should be "Thread.yield()" according to the answers).

I was under impression that the scheduler is completely free to ignore the Thread.yield() hint (as stated in Javadoc) whereas in notify() current thread is guaranteed to pause, at least for a moment, so that other awaiting thread would be notified and awakened.

Re: About Question enthuware.ocpjp.v7.2.1467 :

Posted: Thu Aug 11, 2016 10:58 pm
by admin
The question is only asking about "may". Yield may (possibly) cause the current thread to pause. That is why this option is correct.
Where did you read that notify is guaranteed to pause the current thread? The notification to other waiting thread is handled by the JVM. The current thread will keep running until it comes out of the synchronized block.

-Paul.

Re: About Question enthuware.ocpjp.v7.2.1467 :

Posted: Mon Oct 16, 2017 9:42 am
by horst1a
The question is may, really. I thought a call to wait() forces a thread to stop.