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.
About Question enthuware.ocpjp.v7.2.1467 :
Moderator: admin
-
- Posts: 29
- Joined: Wed Apr 17, 2013 9:22 am
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1467 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 37
- Joined: Mon Jun 12, 2017 2:16 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1467 :
The question is may, really. I thought a call to wait() forces a thread to stop.
Who is online
Users browsing this forum: No registered users and 109 guests