Data race vs race condition
Original post: Data race vs race condition
I really like the distinction Teiva Harsanyi makes between a data race and a race condition:
- A data race occurs when two or more threads simultaneously access the same memory location, and at least one of these accesses is a write operation.
- A race condition refers to any situation where the outcome depends on the timing of events that can’t be controlled, such as which thread runs first.
And from those definitions, he derives this other key conclusion:
All data races are race conditions, yet not all race conditions are data races. It’s important to understand that a data-race-free application doesn’t necessarily guarantee deterministic results.
A short, but very insightful blog post!