About Question enthuware.ocpjp.v7.2.1467 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
insider
Posts: 29
Joined: Wed Apr 17, 2013 9:22 am
Contact:

About Question enthuware.ocpjp.v7.2.1467 :

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

horst1a
Posts: 37
Joined: Mon Jun 12, 2017 2:16 am
Contact:

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

Post by horst1a »

The question is may, really. I thought a call to wait() forces a thread to stop.

Post Reply

Who is online

Users browsing this forum: No registered users and 64 guests