Java OCA OCP Practice Question 1265

Question

Which of the following statements about the wait() and notify() methods is true?

  • A. The wait() and notify() methods can be called outside synchronized code.
  • B. The programmer can set which thread should be notified in a notify() method call.
  • C. The thread that calls wait() goes into the monitor's pool of waiting threads.
  • D. The thread that calls notify() gives up the lock.


C.

Note

The thread that calls wait() goes into the monitor's pool of waiting threads.

Option A is incorrect because wait() and notify() must be called from within synchronized code.

Option B is incorrect because the notify() arbitrarily selects a thread to notify from the pool of waiting threads.

Option D is incorrect because the thread that calls wait() is the thread that gives up the lock.




PreviousNext

Related