Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Races introduced by plausible concurrent code card 2 of 6

Why these races look fine on the page

builds on: Race conditions and interleavings
The race lives *between* two runs of the same code, not in any one line. Tests usually make one call at a time on tiny data, so the bad interleaving rarely happens; green tests prove little here. Two kinds: - **Data race**: two threads touch the same memory, at least one writes, and no synchronization orders them. Race detectors find these. - **Logical race**: each step is safe, but a check and its act, or a read and its write, are separate steps. Race detectors miss these. Later cost: lost updates, half-built objects, crashes under load. All rare, all hard to reproduce.
Terms on this card
data race
Two threads access the same memory, at least one access is a write, and no synchronization orders the accesses. Results can be corrupted or unpredictable.
logical race
Each single access is safe (no data race), but the result still depends on how steps from different tasks interleave. Example: a check and an act done as separate calls.
interleaving
One possible order in which the steps of concurrent tasks actually run, mixed together.
later cost
The concrete damage a shortcut does after merge, such as a hidden bug, corrupted data or extra maintenance.
green
A test or check that passes.
Learn this step by step on Bytewise
Lesson goal: Recognise races that look fine on the page: a Go map written from goroutines, unsynchronized lazy initialisation in Java, check-then-act on a cache, and async read-modify-write in JS. Name which tool or synchronization would catch or fix each one. · the whole lesson