Operating System Design/Critical Section Problem/Monitors
A monitor is a combination of a conditional variable and a lock. It ensures synchronization between threads using busy waiting on a condition variables and then executing it upon reception of the signal from another thread.It can have signal to one thread or broadcast all the threads which are waiting for the lock to be released. A monitor is an object that can be used completely safely by multiple threads. That is, its methods are always executed in mutual exclusion: only one thread can be running a given method at a given point in time. They often provide methods for waiting for access to become available and signaling threads when they can take control.
Many high-level languages (C#, Python, Java, etc.) contain built-in monitor capabilities. For languages that do not support monitors natively, like C, there are concurrency libraries that provide such functionality, like Pthreads.