Slide 5
Slide 5 text
Monitor Instructions (2)
The Java compiler will not produce code that calls MonitorExit without calling MonitorEnter.
Even so, from the JVM perspective such code is totally valid.
In such as case, a MonitorExit instruction with throw an IllegalMonitorStateException.
If a lock is acquired via MonitorEnter, but isn’t released via MonitorExit, other threads trying to obtain it will
block indefinitely.
Since the lock is reentrant, the owning thread may continue to execute even if it were to reach (or reenter)
the same lock again.
So, how is this prevented?
takipi.com