al to  [ std::  atomic  ](http://en.cppreference.com/w/cpp/atomic/atomic) < T  >   
(function macro)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/atomic/dsc_Atomic&action=edit)  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/thread&action=edit&section=5 "Edit
section: Mutual exclusion") ]  Mutual exclusion

Mutual exclusion algorithms prevent multiple threads from simultaneously
accessing shared resources. This prevents data races and provides support for
synchronization between threads.

Defined in header ` [ <mutex> ](/w/cpp/header/mutex "cpp/header/mutex") `  
---  
[ mutex  ](/w/cpp/thread/mutex "cpp/thread/mutex") (C++11)  |  provides basic mutual exclusion facility   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_mutex&action=edit)  
[ timed_mutex  ](/w/cpp/thread/timed_mutex "cpp/thread/timed mutex") (C++11)  |  provides mutual exclusion facility which implements locking with a timeout   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_timed_mutex&action=edit)  
[ recursive_mutex  ](/w/cpp/thread/recursive_mutex "cpp/thread/recursive mutex") (C++11)  |  provides mutual exclusion facility which can be locked recursively by the same thread   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_recursive_mutex&action=edit)  
[ recursive_timed_mutex  ](/w/cpp/thread/recursive_timed_mutex "cpp/thread/recursive timed mutex") (C++11)  |  provides mutual exclusion facility which can be locked recursively   
by the same thread and implements locking with a timeout  
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_recursive_timed_mutex&action=edit)  
Defined in header ` [ <shared_mutex> ](/w/cpp/header/shared_mutex
"cpp/header/shared mutex") `  
[ shared_mutex  ](/w/cpp/thread/shared_mutex "cpp/thread/shared mutex") (C++17)  |  provides shared mutual exclusion facility   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_shared_mutex&action=edit)  
[ shared_timed_mutex  ](/w/cpp/thread/shared_timed_mutex "cpp/thread/shared timed mutex") (C++14)  |  provides shared mutual exclusion facility and implements locking with a timeout   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_shared_timed_mutex&action=edit)  
  
#####  Generic mutex management  
  
Defined in header ` [ <mutex> ](/w/cpp/header/mutex "cpp/header/mutex") `  
[ lock_guard  ](/w/cpp/thread/lock_guard "cpp/thread/lock guard") (C++11)  |  implements a strictly scope-based mutex ownership wrapper   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_lock_guard&action=edit)  
[ scoped_lock  ](/w/cpp/thread/scoped_lock "cpp/thread/scoped lock") (C++17)  |  deadlock-avoiding RAII wrapper for multiple mutexes   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_scoped_lock&action=edit)  
[ unique_lock  ](/w/cpp/thread/unique_lock "cpp/thread/unique lock") (C++11)  |  implements movable mutex ownership wrapper   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_unique_lock&action=edit)  
[ shared_lock  ](/w/cpp/thread/shared_lock "cpp/thread/shared lock") (C++14)  |  implements movable shared mutex ownership wrapper   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_shared_lock&action=edit)  
[ defer_lock_t  try_to_lock_t  adopt_lock_t  ](/w/cpp/thread/lock_tag_t "cpp/thread/lock tag t") (C++11)  (C++11)  (C++11)  |  tag type used to specify locking strategy   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/thread/dsc_lock_tag_t&action=edit)  
[ defer_lock  try_to_lock  adopt_lock  ](/w/cpp/thread/lock_tag "cpp/thread/lock tag") (C+