Mutual Exclusion
Before we look into the solution, let's define some terminology.
- Mutual exclusion prevents multiple threads from entering.
- The critical section is code that only one thread can execute at a time.
- A lock is a mechanism for mutual exclusion.