Advanced Topic 44 of 51 Concurrency & Parallelism
Concurrency Testing
Finding timing bugs with stress and model checking.
How it works
Testing concurrent code is hard because bugs depend on thread interleavings that rarely occur. Techniques include stress tests with many threads and iterations, race detectors such as ThreadSanitizer and Go's race detector, which instrument memory accesses, deterministic schedulers and systematic exploration of interleavings, as in Loom and CHESS, model checking with TLA+ and Spin, fuzzing schedules by injecting random delays, property tests for linearizability such as Jepsen and Lincheck, and code review focused on shared state.
Where it is used
Library authors, database developers and anyone shipping multithreaded or distributed systems rely on these tests to catch data races, deadlocks and atomicity violations.
Common pitfall
Passing tests do not prove correctness, since the bad interleaving may never have happened. Flaky tests are signs of real bugs, not noise to ignore. Sleep-based synchronization in tests is unreliable. Run under sanitizers in CI, on different core counts and loads, keep reproducible seeds and favor designs that reduce shared mutable state.
Where it fits in the course
Concurrency Testing is topic 44 of 51 in Concurrency & Parallelism, rated Advanced. It follows Parallel Graph Algorithms. The next topic is Deterministic Parallelism.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Concurrency & Parallelism quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Concurrency & Parallelism quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Concurrency Testing?
Where do people use Concurrency Testing?
What is the most common mistake with Concurrency Testing?
What should I learn before this topic?
How can I practice it?
Is Concurrency Testing hard to learn?
How long does it take to learn Concurrency Testing?
Which topics are related to Concurrency Testing?
What should I study after Concurrency Testing?
Related topics
- Parallel Graph Algorithms (Concurrency & Parallelism)
- Deterministic Parallelism (Concurrency & Parallelism)
- NUMA (Concurrency & Parallelism)
- Reactive Programming (Concurrency & Parallelism)
- Unit Testing (Software Engineering)
- Integration Testing (Software Engineering)
- Hypothesis Testing (Math for Computing)