What this Python concurrency question tests
This is a medium-difficulty concurrency question that probes your understanding of how Python handles threading, shared state, and the Global Interpreter Lock (GIL). It rewards careful reasoning about execution order and memory visibility rather than rote knowledge of threading APIs.
To work through problems like this, you need to trace the interleaving of thread operations, predict which values are visible at each point, and account for Python's synchronisation semantics. Firms ask these questions to identify candidates who can reason about real concurrent bugs—race conditions, stale reads, and unexpected state mutations—rather than those who merely memorise threading library names.
- Thread scheduling and execution order non-determinism
- Shared mutable state and visibility across threads
- The GIL and its implications for true parallelism
- Print statement buffering and output ordering