warming up your workspace

Race condition

Applies to: general

A race condition is a bug where the result depends on the unpredictable timing of concurrent operations on shared data. Two threads reading, incrementing, and writing the same counter can lose an update. A mutex or atomic operation fixes it.

T1 read 5   T2 read 5   T1 write 6   T2 write 6   # lost an increment

See also: thread, mutex