🎉 October Learning Month — learn a new software term every day!
An interactive flashcard trainer for software engineering terms.

Mutex

In plain terms

A lock that ensures only one thread touches shared data at a time.

Going deeper

A mutex ('mutual exclusion') is acquired before entering a critical section and released after, serializing access so concurrent threads don't corrupt shared state. Misuse can cause deadlocks or slowdowns.

Under the hood

Blocking and potentially costly under contention; alternatives include read-write locks, spinlocks for short critical sections, and lock-free structures using atomic CAS.

Examples

pthread_mutex, Java synchronized, Go sync.Mutex, std::mutex in C++.

Think of it like...

Like the single key to a one-person restroom: you must hold the key to enter, and others wait until you hang it back up.

Feedback & Bug Report