Multiple choice

The methods wait(), notify() and notifyAll() must be called only when they own the monitor of that object, otherwise they throw __________________.

  1. IllegalMonitorException

  2. IllegalStateException

  3. IllegalMonitorStateException

  4. IllegalMonitorOwnStateException

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

All these methods must be called only when they own the monitor of that object, otherwise they throw IllegalMonitorStateException exception. These methods are used for proper coordination among the threads.