A mutex admits only one job into code that mutates shared state. The owner releases the lock, allowing a waiting job to enter next.
An overly broad lock reduces parallelism, while a missed release blocks everyone else. Keep the critical section short and release on error paths.
When to use
Use it when multiple threads mutate the same structure.