monitorexit :
leave synchronized region of code : index : visitInsn()
- Description
- This releases an exclusive lock that was previously obtained using
monitorenter for the object objectref. If other threads are
waiting for the object to become unlocked, one of the waiting threads will be
able to acquire a lock on the object and proceed.
Note that a single thread can lock an object several times - the runtime system
maintains a count of the number of times that the object was locked by the
current thread, and only unlocks the object when the counter reaches zero (i.e.
when the number of monitorenters and monitorexits applied to
a given object are equal).
The monitorenter/monitorexit mechanism is used by the Java
synchronized statement to coordinate access to an object among
multiple threads. - Exceptions
- NullPointerException - objectref is null.
IllegalMonitorStateException - objectref was not previously locked by
the current thread. - See also
- monitorenter
- Stack
Before
|
After |
objectref |
... |
... |
... |
- Bytecode
Type
|
Description |
u1 |
monitorexit
opcode = 0xC3 (195)
|