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
E is correct, when you call notify() on a monitor, you have no control over which waiting thread gets notified.
Disclaimer: All Simulation Exams practice tests, study guides and/or material are neither sponsored by, nor endorsed by, nor affiliated with Oracle® or any other company. All trademarks are trademarks of their respective owners and duly acknowledged. OCA™, OCPJP™, SCJP™ are registered trade marks of Oracle®. . The practice tests material is a copyright of SimulationExams.com and the same is not approved or endorsed by respective certifying bodies. Thank-you for your interest in Simulation Exams. Please see read me file before you download, install, and/or use any software from SimulationExams.com For any information or questions regarding this Website, please e-mail webmaster at simulationexams.com