Concurrency in C++
Threads, synchronisation primitives, atomics and parallel algorithms.
This is an overview — pick a sub-topic below.
Sub-topics (12)
std::thread
Run a function on a new thread.
Mutexes
Ensure only one thread at a time accesses shared data.
Locks
RAII wrappers that lock and unlock mutexes automatically.
std::condition_variable
Wait until another thread signals that a condition holds.
Futures and Promises
A promise sets a value; a future retrieves it later, possibly from another thread.
std::async
Run a function asynchronously and get a `std::future` for the result.
std::atomic
Lock-free operations on shared variables.
Memory Ordering
`memory_order_relaxed`, `acquire`, `release`, `seq_cst` control visibility of writes between threads.
Thread Safety
Code is thread-safe if concurrent use cannot cause data races or broken invariants.
Parallel Algorithms
Run standard algorithms in parallel with execution policies (C++17).
Coroutines for Concurrency
Asynchronous code that reads sequentially — used with networking and task libraries.
Executors and std::execution
A model for describing where and how work runs (senders/receivers), standardised for C++26.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.