A monitor is an exclusive locking mechanism available to every managed object. When you are writing instance methods within a class to update and read instance fields, you can utilize the monitor of the current object to synchronize access. A thread can use a monitor to block other threads for the period of time during which it is making a series of updates to an object. That means a monitor can be used in order to block other threads from seeing any single update until all of the updates have been completed.
A monitor type presents a set of programmer-defined operations that are provided mutual exclusion within the monitor. The monitor type also contains the declaration of variables whose values define the state of an instance of that type, along with the bodies of procedures or functions that operate on those variables.
The monitor construct ensures that only one process at a time can be
active within the monitor. However, the monitor construct, as defined so far, is not sufficiently powerful for modeling some synchronization schemes. For this purpose, we need to define
additional synchronization mechanisms. These mechanisms are provided by the condition construct. A programmer who needs to write a tailor-made synchronization scheme can define one or more variables of type condition:
condition x, y;
The only operations that can be invoked on a condition variable are wait ()
and signal(). The operation x.waitO ;
means that the process invoking this operation is suspended until another
process invokes x . s i g n a l ( ) ;
The x. signal () operation resumes exactly one suspended process. If no
process is suspended, then the signal () operation has no effect; that is, the
state of x is the same as if the operation had never been executed .
This is showing how monitor is operating