C++ Concurrency Library

C++ Concurrency Library

Threads, jthread, stop tokens, mutexes, atomics, futures, semaphores, latches, barriers, and the main coordination tools in the standard library.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

C++ Concurrency Library

Threads and cancellation

Mutual exclusion and locking

Waiting and coordination

Futures and task abstractions

Atomics

Practical choice rules

Example in practice

#include <thread>
#include <mutex>

int main() {
    std::mutex guard;
    std::jthread worker([&] {
        std::scoped_lock lock(guard);
    });
}