liveBook · Manning

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.

How 5 Manning books explain it

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.

Read how The Coder Cafe explains data race →

Also covered in

What to know first

Related concepts

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.