C++ Concurrency in Action
C++ Concurrency in Action
Summary:
Introduction
The book "C++ Concurrency in Action" (second edition, 2019) by Anthony Williams is arguably the most authoritative and in-depth textbook on multithreaded and parallel programming in C++. The author, a member of the C++ standardization committee and developer of the just::thread library, does not merely describe syntax but teaches you to think in terms of concurrency, avoid data races, and build efficient, safe, and scalable systems. The book covers both basic mechanisms (std::thread, mutexes, condition variables) and advanced topics (atomic operations, lock-free structures, the C++ memory model).
What the book is about
The 2019 edition has been completely revised for the C++14 and C++17 standards. The book consists of 13 chapters divided into two parts: fundamentals and advanced techniques. The first part introduces thread management, protecting shared data, synchronization, and asynchronous tasks. The second part delves into atomic types, the C++ memory model, designing lock-free containers, parallel algorithms, and testing multithreaded code. Each chapter contains numerous practical examples, from a simple thread pool to implementing a lock-free queue.
Who this book is for
The book is intended for experienced C++ developers who are already confident writing in C++11/14/17 and want to master multithreading. Beginners in C++ will find it challenging — knowledge of templates, smart pointers, lambda expressions, and the STL is assumed. However, if you already have basic experience with threads in other languages (Java, C#) and want to understand the specifics of C++, this book will serve as an excellent bridge.
What the reader will learn
- Thread management: creation, joining, detaching, argument passing, thread identification.
- Protecting shared data: std::mutex, std::lock_guard, std::unique_lock, recursive and shared mutexes, deadlock and its prevention.
- Synchronization: condition variables (std::condition_variable), std::future, std::promise, std::packaged_task, std::async.
- Atomic operations: std::atomic, ordering models (relaxed, acquire, release, seq_cst), memory barriers.
- C++ memory model: formal description of happens-before, synchronization, data races.
- Lock-free programming: designing lock-free stacks, queues, hash tables.
- Parallel algorithms: std::for_each, std::find, std::reduce with execution policies (std::execution::par).
- Testing and debugging: finding races, testing multithreaded code, tools (ThreadSanitizer).
Strengths
The main advantage of the book is its depth and precision. Anthony Williams not only shows how to use the API but also explains why the code works the way it does, what guarantees the standard provides, and how to avoid pitfalls. The detailed description of the C++ memory model — a topic that usually remains a "black box" for most developers — is especially valuable. The code examples are realistic, well-commented, and often accompanied by diagrams. The second edition includes a chapter on STL parallel algorithms and updated examples for C++17.
Who should read it
The book is a must-read for anyone writing high-load servers, game engines, financial systems, databases, or any other software where performance and correctness under parallel execution are critical. It will also be useful for library and framework developers who want to create thread-safe components. If you are preparing for an interview at a company that actively uses C++ (for example, in HFT, game development, or systems programming), this book will provide you with the fundamental knowledge that will set you apart from other candidates.