About 133,000 results
Open links in new tab
  1. multithreading - What is a mutex? - Stack Overflow

    Aug 29, 2008 · A mutex is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a mutex and how do you use it?

  2. std::mutex - cppreference.com

    Mar 6, 2024 · The mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads. mutex offers exclusive, non-recursive …

  3. Standard library header <mutex> (C++11) - cppreference.com

    Jul 3, 2024 · Class std::mutex namespace std { class mutex { public: constexpr mutex () noexcept; ~mutex (); mutex (const mutex &) = delete; mutex & operator =(const mutex &) = delete; void lock (); …

  4. std::mutex::mutex - cppreference.com

    Oct 22, 2023 · 1) Constructs the mutex. The mutex is in unlocked state after the constructor completes.

  5. c++ - How do mutexes really work? - Stack Overflow

    Aug 2, 2012 · However, how is this implemented? To lock itself, the mutex has to set a bit somewhere that says that it is locked. But what if the second mutex is reading at the same time the first is writing. …

  6. multithreading - What does a mutex lock? - Stack Overflow

    Sep 29, 2022 · Mutex doesn't know anything about other variables. It is locking itself. That is, the underlying OS will know that a process that is trying to acquire a locked mutex should not be …

  7. Can someone Explain Mutex and how it is used? - Stack Overflow

    Aug 20, 2010 · A mutex provides mut ually ex clusive access to a resource; in your case, a database. There aren't multiple threads in your program, but you can have multiple instances of your program …

  8. c++ - Mutex example / tutorial? - Stack Overflow

    The function pthread_mutex_lock() either acquires the mutex for the calling thread or blocks the thread until the mutex can be acquired. The related pthread_mutex_unlock() releases the mutex.

  9. How does a Mutex work? Does a mutex protect variables globally?

    Jun 13, 2016 · Mutex stands for "Mutual Exclusion" - using one correctly ensures that only one thread at a time will ever be executing any "critical section" protected by the same mutex. If there are some …

  10. std::mutex::lock - cppreference.com

    Oct 22, 2023 · Locks the mutex. If another thread has already locked the mutex, a call to lock will block execution until the lock is acquired. If lock is called by a thread that already owns the mutex, the …