What this concurrency interview question tests
This is a foundational operating-systems question that probes whether you understand the core challenge of multi-threaded programming: the race condition. When multiple threads read from and write to the same memory location without synchronisation, the final state of that data becomes unpredictable and depends on the precise interleaving of thread execution.
Interviewers ask this to establish whether you grasp why synchronisation primitives (locks, atomics, barriers) exist at all. The question rewards a clear explanation of how non-deterministic scheduling can corrupt shared state, and ideally an intuition for why simple solutions like "just add a lock" come with trade-offs in correctness and performance.
- Thread scheduling and execution interleaving
- Read-modify-write hazards
- Memory visibility and visibility guarantees
- Critical sections and mutual exclusion