Nepedia
Back to Discover
Independent Reader
💻

Monitor (synchronization)

technology Maturity 11-13 war conflict Next article →

This article covers sensitive topics: war_conflict. Parents can manage visibility in Parental Controls.

Computers often do many tasks at the same time. These tasks are called threads. Sometimes, threads must share the same object. This can cause mistakes if they do not work together. A monitor is a tool that keeps sharing safe.

Monitor (synchronization)-SU
Monitor (synchronization)-SU

A monitor uses a mutex. A mutex is a lock. It makes sure only one thread uses the object at a time. This is called mutual exclusion. When a thread starts a task, it locks the mutex. When the task ends, it unlocks it. This stops errors like data races. A data race is a mistake that happens when threads clash.

Sometimes, a thread cannot finish its task yet. It might need to wait for a change. A monitor uses condition variables to help. A condition variable is a way for a thread to wait.

Monitor (synchronization)-Mesa
Monitor (synchronization)-Mesa

Instead of checking the object over and over, the thread goes to sleep. This saves power. When the state changes, another thread sends a signal. This signal wakes up the waiting thread. The waiting thread then grabs the lock again to finish its work.

Monitor (synchronization)-Java
Monitor (synchronization)-Java
179 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (3)
File:Monitor (synchronization)-SU.png
Monitor (synchronization)-SU.png
File:Monitor (synchronization)-Mesa.png
Monitor (synchronization)-Mesa.png
File:Monitor (synchronization)-Java.png
Monitor (synchronization)-Java.png
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.