Answers for "cpp mutex"

C++
0

cpp mutex

#include <mutex>
#include <vector>
std::mutex door;    // mutex declaration
std::vector<int> v; // shared data
door.lock();
/*-----------------------*/
/* This is a thread-safe zone: just one thread at the time allowed
 * 
 * Unique ownership of vector v guaranteed 
 */
/*-----------------------*/
door.unlock();
Posted by: Guest on October-22-2021

Browse Popular Code Answers by Language