[ atomic_flag_notify_all  ](/w/cpp/atomic/atomic_flag_notify_all
"cpp/atomic/atomic flag notify all") (C++20)  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/navbar_content&action=edit)

C++ includes built-in support for threads, atomic operations, mutual
exclusion, condition variables, and futures.

##  Contents

  * 1  Threads 
    * 1.1  Functions managing the current thread 
  * 2  Thread cancellation 
  * 3  Cache size access 
  * 4  Atomic operations 
    * 4.1  Atomic types 
    * 4.2  Operations on atomic types 
    * 4.3  Flag type and operations 
    * 4.4  Initialization 
    * 4.5  Memory synchronization ordering 
    * 4.6  C compatibility macros 
  * 5  Mutual exclusion 
    * 5.1  Generic mutex management 
    * 5.2  Generic locking algorithms 
    * 5.3  Call once 
  * 6  Condition variables 
  * 7  Semaphores 
  * 8  Latches and Barriers 
  * 9  Futures 
    * 9.1  Future errors 
  * 10  Safe Reclamation 
    * 10.1  Read-Copy-Update Mechanism 
    * 10.2  Hazard Pointers 
  * 11  See also 

  
---  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/thread&action=edit&section=1 "Edit
section: Threads") ]  Threads

Threads enable programs to execute across several processor cores.

Defined in header ` [ <thread> ](/w/cpp/header/thread "cpp/header/thread") `  
---  
[ thread  ](/w/cpp/thread/thread "cpp/thread/thread") (C++11)  |  manages a separate thread   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_thread&action=edit)  
[ jthread  ](/w/cpp/thread/jthread "cpp/thread/jthread") (C++20)  |  [ std::thread ](/w/cpp/thread/thread "cpp/thread/thread") with support for auto-joining and cancellation   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_jthread&action=edit)  
  
#####  Functions managing the current thread  
  
Defined in namespace ` this_thread `  
[ yield  ](/w/cpp/thread/yield "cpp/thread/yield") (C++11)  |  suggests that the implementation reschedule execution of threads   
(function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_yield&action=edit)  
[ get_id  ](/w/cpp/thread/get_id "cpp/thread/get id") (C++11)  |  returns the thread id of the current thread   
(function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_get_id&action=edit)  
[ sleep_for  ](/w/cpp/thread/sleep_for "cpp/thread/sleep for") (C++11)  |  stops the execution of the current thread for a specified time duration   
(function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_sleep_for&action=edit)  
[ sleep_until  ](/w/cpp/thread/sleep_until "cpp/thread/sleep until") (C++11)  |  stops the execution of the current thread until a specified time point   
(function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_sleep_until&action=edit)  
  
###  Thread cancellation

The ` stop_XXX ` types are designed to enable thread cancellation for ` std::jthread ` , although they can also be used independently of ` std::jthread ` \- for example to interrupt ` std::condition_variable_any ` waiting functions, or for a custom thread management implementation. In fact they do not even need to be used to "stop" anything, but can instead be used for a thread-safe one-time function(s) invocation trigger, for example.  |  Defined in header ` [ <stop_token> ](/w/cpp/header/stop_token "cpp/header/stop token") `  
---  
[ stop_token  ](/w/cpp/thread/stop_token "cpp/thread/stop token") (C++20)  |  an interface for querying if a  [ std::jthread ](/w/cpp/thread/jthread "cpp/thread/jthread") cancellation request has been made   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_stop_token&action=edit)  
[ stop_source  ](/w/cpp/thread/stop_source "cpp/thread/stop source") (C++20)  |  class representing a request to stop one or more  [ s