Concurrency in C++: Multithreading, Asynchrony, and Parallelism
300 pages
English
PDF
4.5

Concurrency in C++: Multithreading, Asynchrony, and Parallelism

Concurrency in C++: Multithreading, Asynchrony, and Parallelism

Author:

Year:

Summary:

Modern processors have multiple cores, and to harness their full power, you need to be able to write concurrent code. The book "Concurrency in C++" is a comprehensive guide that will help you master all aspects of parallel programming in C++: from basic threads to complex synchronization patterns.



The book starts with the basics: you will learn how to create and manage threads using the standard library (std::thread), how to protect shared data with mutexes (std::mutex), and how to avoid deadlocks. Special attention is paid to modern C++11/14/17/20 features such as std::async, std::future, std::promise, and std::packaged_task, which allow you to write asynchronous code without manual thread management.



You will also become familiar with the C++ memory model, atomic operations (std::atomic), and memory barriers — these topics are critically important for creating correct and efficient concurrent algorithms. A separate chapter is dedicated to design patterns for multithreaded applications: thread pool, producer-consumer, readers-writers lock, and others.



The practical part of the book includes an analysis of real-world examples: parallel data processing, concurrent queues, lock-free data structures, and performance optimization. You will learn to identify and fix common errors: data races, deadlocks, false sharing, and caching issues.



Who this book is for:

  • C++ developers who want to write fast multithreaded applications
  • Programmers transitioning from single-threaded to concurrent projects
  • Specialists preparing for interviews where multithreading is asked
  • Anyone who wants to understand how parallelism works at the system level


What you will learn:

  • How to create and synchronize threads in C++
  • How to use std::async, std::future, and std::promise for asynchronous tasks
  • How the C++ memory model and atomic operations work
  • How to design thread-safe classes and containers
  • How to avoid deadlocks, data races, and other problems
  • How to profile and optimize concurrent code
  • How to apply lock-free and wait-free algorithms


The book contains many code examples that you can immediately apply in your projects. All examples are tested under GCC, Clang, and MSVC. After reading, you will be able to confidently write concurrent programs that efficiently use multi-core processors and work without errors.



This is not dry theory, but a practical guide based on the author's many years of experience. You will gain a deep understanding of how concurrency works in C++ and learn to apply this knowledge in practice.

Recommendations