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
- Diagnoses unsafe concurrent access to shared Go variables, slices, and maps.
- How deep it goes
- Works through interleaved reads and writes and practical fixes, without surveying every synchronization option.
- Examples
- Uses competing increments, concurrent slice appends, map iteration after unlocking, and a copied mutex.
- What you can do after
- Diagnose/debug with `-race`, then protect shared access or give goroutines independent data.
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 →
Related concepts
- lockingaddressed by · Locking is a synchronization technique that restricts concurrent access to shared resources or protected operations.
- race conditionkind of · A race condition is a concurrency defect in which program behavior or results depend on the relative timing or ordering of interacting operations.
- undefined behaviorproduces · Undefined behavior is program execution for which the applicable language or system specification imposes no requirements on the resulting behavior or effects.
- 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.
- memory orderingaddressed by · Memory ordering is the set of rules governing the permitted ordering and visibility of memory operations across concurrent execution contexts.
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.



