+11)  (C++11)  (C++11)  |  tag constants used to specify locking strategy   
(constant)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_lock_tag&action=edit)  
  
#####  Generic locking algorithms  
  
[ try_lock  ](/w/cpp/thread/try_lock "cpp/thread/try lock") (C++11)  |  attempts to obtain ownership of mutexes via repeated calls to ` try_lock `   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_try_lock&action=edit)  
[ lock  ](/w/cpp/thread/lock "cpp/thread/lock") (C++11)  |  locks specified mutexes, blocks if any are unavailable   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_lock&action=edit)  
  
#####  Call once  
  
[ once_flag  ](/w/cpp/thread/once_flag "cpp/thread/once flag") (C++11)  |  helper object to ensure that [ ` call_once ` ](/w/cpp/thread/call_once "cpp/thread/call once") invokes the function only once   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_once_flag&action=edit)  
[ call_once  ](/w/cpp/thread/call_once "cpp/thread/call once") (C++11)  |  invokes a function only once even if called from multiple threads   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_call_once&action=edit)  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/thread&action=edit&section=6 "Edit
section: Condition variables") ]  Condition variables

A condition variable is a synchronization primitive that allows multiple
threads to communicate with each other. It allows some number of threads to
wait (possibly with a timeout) for notification from another thread that they
may proceed. A condition variable is always associated with a mutex.

Defined in header ` [ <condition_variable> ](/w/cpp/header/condition_variable
"cpp/header/condition variable") `  
---  
[ condition_variable  ](/w/cpp/thread/condition_variable "cpp/thread/condition variable") (C++11)  |  provides a condition variable associated with a  [ std::unique_lock ](/w/cpp/thread/unique_lock "cpp/thread/unique lock")   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_condition_variable&action=edit)  
[ condition_variable_any  ](/w/cpp/thread/condition_variable_any "cpp/thread/condition variable any") (C++11)  |  provides a condition variable associated with any lock type   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_condition_variable_any&action=edit)  
[ notify_all_at_thread_exit  ](/w/cpp/thread/notify_all_at_thread_exit "cpp/thread/notify all at thread exit") (C++11)  |  schedules a call to ` notify_all ` to be invoked when this thread is completely finished   
(function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_notify_all_at_thread_exit&action=edit)  
[ cv_status  ](/w/cpp/thread/cv_status "cpp/thread/cv status") (C++11)  |  lists the possible results of timed waits on condition variables   
(enum)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_cv_status&action=edit)  
  
###  Semaphores

A semaphore is a lightweight synchronization primitive used to constrain concurrent access to a shared resource. When either would suffice, a semaphore can be more efficient than a condition variable.  |  Defined in header ` [ <semaphore> ](/w/cpp/header/semaphore "cpp/header/semaphore") `  
---  
[ counting_semaphore  ](/w/cpp/thread/counting_semaphore "cpp/thread/counting semaphore") (C++20)  |  semaphore that models a non-negative resource count   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_counting_semaphore&action=edit)  
[ binary_semaphore  ](/w/cpp/thread/counting_semaphore "cpp/thread/counting semaphore") (C++20)  |  semaphore that has only two states   
(typedef)  [ [edit]
](https://