Java OCA OCP Practice Question 2288

Question

Which statements are true about locks?.

Select the two correct answers.

  • (a) A thread can hold more than one lock at a time.
  • (b) Invoking wait() on a Thread object will relinquish all locks held by the thread.
  • (c) Invoking wait() on an object whose lock is held by the current thread will relinquish the lock.
  • (d) Invoking notify() on a object whose lock is held by the current thread will relinquish the lock.
  • (e) Multiple threads can hold the same lock at the same time.


(a) and (c)

Note

A thread can hold multiple locks; e.g., by nesting synchronized blocks.

Invoking the wait() method on an object whose lock is held by the current thread will relinquish the lock for the duration of the call.

The notify() method does not relinquish any locks.




PreviousNext

Related