Skip to interview prep
Apexed

34. What is a race condition? Give an example.

MediumOS, networking & concurrency

Technical
Show model answer

A race condition is a bug where the result depends on the timing of concurrent operations. Classic example: two threads run `count = count + 1` at once; both read 5 and both write 6, losing an increment.

Fix it with atomic operations, locks around the critical section, or by avoiding shared mutable state.

What is a race condition? Give an example. — Software engineering interview question — Apexed