A monitor is a synchronization object which can be locked for read, browse, and write operations. This type of synchronization is typically used to protect a data structure in which different threads might want to read and write.
A monitor can only be used as an intra-process synchronization object.
Any monitors created or opened using the library routines are automatically closed when the run-time system terminates (for example, as a consequence of a STOP RUN).
A write lock locks out all other read, browse, and write locks. Typically, a write lock is used when writing to the data structure.
A browse lock locks out other write and browse locks, but allows simultaneous read locks. Typically, a browse lock is used when reading a data structure with a view to writing to it depending on the results of the read. To this end, a function is provided to convert a browse lock to a write lock without letting in any other writers.
A read lock only locks out write locks. Typically, a read lock is used when reading a data structure without any intention of writing to it.
If a thread has acquired a lock, the results of attempting to acquire a further lock before that original lock has been released are undefined except in the case where a conversion to or from a browse lock is performed.