DELAPARRA
Index
Color
NL
Category: Programming paradigms

Race Condition

Explained by Updated

What is Race Condition?

Race Condition: A bug where the outcome depends on the unpredictable timing/order of concurrent operations touching shared state. A race condition occurs when several concurrent operations touch shared state and the result depends on their unpredictable order. The code is correct when run alone and wrong when run in parallel. Classic examples are lost updates, where two processes overwrite each other's change, and check-then-act bugs, where a condition is true when checked but no longer true when acted on, such as a username that was free a moment ago.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Race Condition

What should you keep in mind with Race Condition?

Prevention means making the critical part atomic. Databases offer atomic updates, transactions with row locks, and unique constraints. Languages offer mutexes, atomic variables and channels. Designing to avoid shared mutable state, as the actor model and immutable data do, removes many race conditions at the root. Tests that run operations in parallel can help reproduce them before users do.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with R

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.