Operating System Design/Critical Section Problem/Monitors
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.