What is a race condition?

What is a race condition?

Approach: Explain dependency on timing or interleaving.

An anomaly where the program behavior depends on the relative timing of interleaved execution of multiple threads, potentially leading to incorrect state.

Follow-up: How do you prevent race conditions?

Key concepts: critical section, atomicity, mutual exclusion.