Top "Mutex" questions

A mutex ("mutual exclusion") is a mechanism to ensure integrity when the same data or resource is accessed (in particular, changed) concurrently from several threads.

std::mutex vs std::recursive_mutex as class member

I have seen some people hate on recursive_mutex: http://www.zaval.org/resources/library/butenhof1.html But when thinking …

c++ c++11 mutex object-design recursive-mutex
using std::cout in multiple threads

I write a simple program for testing Thread in c++11 but std::cout doesnt work as I expect. class Printer { …

c++ multithreading c++11 mutex stdthread
Singleton with multithreads

This question was asked in an interview. The first part was to write the singleton class: class Singleton { static Singleton *…

c++ multithreading synchronization singleton mutex
std::mutex performance compared to win32 CRITICAL_SECTION

how does the performance of std::mutex compared to CRITICAL_SECTION? is it on par? I need lightweight synchronization object (…

c++ stl synchronization thread-safety mutex
C Confused on how to initialize and implement a pthread mutex and condition variable

I'm a little bit confused on how to initialize and implement a pthread mutex and condition variable. The goal of …

c pthreads conditional-statements mutex producer-consumer
boost scoped_lock vs plain lock/unlock

I'm going to use boost::mutex from boost/thread/mutex.hpp. There are several ways to lock/unlock mutex: with …

c++ boost thread-safety mutex
How can I tell if another instance of my program is already running?

How do i tell if one instance of my program is running? I thought I could do this with a …

delphi persistence mutex instance semaphore
Advantages of using condition variables over mutex

I was wondering what is the performance benefit of using condition variables over mutex locks in pthreads. What I found …

multithreading variables pthreads mutex conditional-statements
How can I use something like std::vector<std::mutex>?

I have a large, but potentially varying, number of objects which are concurrently written into. I want to protect that …

c++ multithreading c++11 vector mutex
C++11 equivalent to boost shared_mutex

Is there a C++11 equivalent for the boost::shared_mutex. Or another solution to handle a multiple reader / single writer …

c++ boost c++11 mutex