All the documentation I\'ve read on the pthreads mutex states only that a mutex prevents multiple threads from accessing shared memory, but how do you specify in the program
Mutex locks a piece of code. For example:
mutex.lock(); //some code here mutex.unlock();
If one thread enters the code above it locks it, until it is done with it. At the same time no other thread can execute this piece of code.
mutex and threads independence