Data race
A data race is a concurrent access to shared data in which at least one access is a write and the accesses are not adequately synchronized.
100 Go Mistakes and How to Avoid Them
A data race is a concurrency error in which multiple executions access the same memory concurrently, at least one access is a write, and the accesses are not properly ordered or synchronized.
- How it is used
- Uses data races to diagnose unsafe shared-memory access in concurrent Go programs.
- How deep it goes
- Traces increment interleavings and explains synchronization and shared-storage pitfalls, while omitting some atomic options.
- Examples
- Uses shared increments, concurrent slice appends, map iteration, and a counter with a copied mutex.
- What you can do after
- Diagnose/debug races with Go’s race detector and choose synchronization or data copying for the demonstrated cases.
Read how 100 Go Mistakes and How to Avoid Them explains data race →
Learn Go with Pocket-Sized Projects
A data race is a concurrency defect in which multiple execution contexts access the same memory concurrently and at least one access modifies it without adequate synchronization.
- How it is used
- Diagnoses concurrent cache defects through parallel tests, race-enabled test runs, and synchronization.
- How deep it goes
- Defines conflicting concurrent access, demonstrates a race report, and applies mutexes; it stops short of proving undetected races absent.
- Examples
- Uses parallel cache writes and concurrently explored maze pixels to demonstrate conflicting access and undefined behavior.
- What you can do after
- Diagnose/debug with go test -race, then protect shared cache state with mutexes and deferred unlocks.
Read how Learn Go with Pocket-Sized Projects explains data race →
C++ Concurrency in Action, Second Edition
A data race occurs when concurrent operations access the same memory location, at least one operation modifies it, and the operations are not properly synchronized.
- How it is used
- Identifies unsynchronized conflicting access as a correctness hazard in shared data, initialization, and parallel algorithms.
- How deep it goes
- Defines the access and ordering conditions, explains undefined behavior, and illustrates hazards without developing the full memory model.
- Examples
- Uses double-checked resource initialization and a parallel lambda that modifies a shared counter.
- What you can do after
- Evaluate whether concurrent accesses require ordering and whether atomic operations or synchronization make them defined.
Read how C++ Concurrency in Action, Second Edition explains data race →
Rust Servers, Services, and Apps
A data race is an unsynchronized concurrent access to shared data in which at least one access mutates the data.
- How it is used
- Uses compile-time ownership and thread-safety checks to make multithreaded programs safer.
- How deep it goes
- Defines the safety problem and identifies compiler enforcement, while deferring deeper treatment to Send and Sync traits and concurrency references.
- Examples
- Uses cross-thread sharing of non-thread-safe objects as the concrete failure case.
- What you can do after
- Evaluate multithreaded Rust designs through compiler-enforced ownership and thread-safety guarantees.
Read how Rust Servers, Services, and Apps explains data race →
The Coder Cafe
A data race is a concurrent execution in which multiple threads access the same memory location, with at least one access being a write, without adequate synchronization.
- How it is used
- Explains a central safety problem that arises when concurrent software shares mutable memory.
- How deep it goes
- Defines the memory-access pattern, contrasts it with race conditions, and demonstrates mutex-based mitigation without descending into implementation internals.
- Examples
- Uses a shared coffee price, mutex-protected access, social-media likes, and an outdated bank balance.
- What you can do after
- Diagnose unsynchronized shared-memory access and apply a mutex while recognizing that race conditions may remain.
Also covered in
- Rust in Action: Systems programming concepts and techniques
- Go by Example
- Learn Rust in a Month of Lunches
- Embedded Software with RustIn early access (MEAP)
What to know first
- threadA thread is a distinct sequence of execution with its own control flow and state, managed or scheduled by a processor, runtime, or operating system.
- concurrencyConcurrency is the structuring or execution of multiple computational activities so their progress overlaps in time, whether or not they run simultaneously.
- iteratorAn iterator is an object or abstraction that provides successive values from a collection or other data source through a traversal interface.
- lockingLocking is a synchronization technique that controls concurrent access to a shared resource or protected operation.
Related concepts
- lockingaddressed by · Locking is a synchronization technique that controls concurrent access to a shared resource or protected operation.
- race conditionkind of · A race condition is a concurrency defect in which program behavior or results depend on the timing or ordering of interacting operations.
- undefined behaviorproduces · Undefined behavior is program execution or an operation for which the applicable specification imposes no requirements on the resulting behavior.
- race-condition detectionmeasured by · Race-condition detection is dynamic analysis of concurrent program execution that identifies conflicting unsynchronized accesses to shared data.
- slice copyaddressed by · A slice copy is the technique of copying selected elements into a separately allocated slice so the result does not retain the source array.
- bugkind of · A software bug is a defect that can cause software to behave incorrectly or differently from its intended or specified behavior.
Questions about data race
What is data race?
A data race is a concurrent access to shared data in which at least one access is a write and the accesses are not adequately synchronized.
Which Manning books explain data race?
100 Go Mistakes and How to Avoid Them, Learn Go with Pocket-Sized Projects, C++ Concurrency in Action, Second Edition, Rust Servers, Services, and Apps and The Coder Cafe.
What should I know before learning data race?
Manning books that teach data race usually introduce thread, concurrency, iterator and locking first.
What is data race a kind of?
Data race is a kind of race condition. A race condition is a concurrency defect in which program behavior or results depend on the timing or ordering of interacting operations.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




