Contents | Prev | Next | Index

monitorexit

Operation

monitorexit
Exit monitor for object

Forms
monitorexit = 195 (0xc3)

Stack
..., objectref ...

Description
The objectref must be of type reference.

The current thread must be the owner of the monitor associated with the instance referenced by objectref. The thread decrements the counter indicating the number of times it has entered this monitor. If as a result the value of the counter becomes zero, the current thread releases the monitor. If the monitor associated with objectref becomes free, other threads that are waiting to acquire that monitor are allowed to attempt to do so.

Runtime Exceptions
If objectref is null, monitorexit throws a NullPointerException.

Otherwise, if the current thread is not the owner of the monitor, monitorexit throws an IllegalMonitorStateException.

Notes
For detailed information about threads and monitors in the Java Virtual Machine, see Chapter 8, "Threads and Locks."


Contents | Prev | Next | Index

Java Virtual Machine Specification (HTML generated by dkramer on February 25, 1997)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com