Contents Prev Next Up

## The Virtual Machine Instruction Set

# Monitors

monitorenter
monitorexit

### monitorenter

Enter monitored region of code

    ..., handle => ...

handle should be a handle to an object.

The interpreter attempts to obtain exclusive access via a lock mechanism to handle. If another process already has handle locked, than the current process waits until the handle is unlocked. If the current process already has handle locked, then continue execution. If handle has no lock on it, then obtain an exclusive lock.

### monitorexit

Exit monitored region of code

    ..., handle => ...

handle should be a handle to an object.

The lock on handle is released. If this is the last lock that this process has on that handle (one process is allowed to have multiple locks on a single handle), then other processes that are waiting for handle to be free are allowed to proceed.

Contents Prev Next Up

Generated with CERN WebMaker