Sim-Ex™ Practice Exams for Java SE 8 Programmer II: Sample Questions

Threads

Home     Previous     Up     Next

Q8. A monitor called mon has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?

A. Execute notify(thread1); from within synchronized code of mon.

B. Execute mon.notify(thread1); from synchronized code of any object.

C. Execute thread1.notify(); from synchronized code of any object.

D. Execute thread1.notify(); from any code(synchronized or not) of any object.

E. You cannot specify which thread will get notified.

Correct Answer: E

Explanation:

E is correct, when you call notify() on a monitor, you have no control over which waiting thread gets notified.

Home     Previous     Up     Next


Disclaimer: Simulationexams.com is not affiliated with any certification vendor, and Sim-Ex™ Practice Exams are written independently by SimulationExams.com and not affiliated or authorized by respective certification providers. Sim-Ex™ is a trade mark of SimulationExams.com or entity representing Simulationexams.com.SCJP® is a trademark of Oracle™.