26 Aug
2015
26 Aug
'15
8:02 a.m.
Il 25/08/2015 13:31, Don El Ron ha scritto: It seems that each myResource instannstance has its own mutex, so if you pass it by copy in the MyWorkerXX constructors each of the MyWorkerXX instance will lock on a different mutex. This can be avoided in many ways, it depends on what kind of locking is required: 1) if each MyResource still needs a separate mutex, then you should pass it to MyWorkerXX class by reference, so each worker thread will lock on the same mutex 2) if all of MyResouce instances must be synchronized on the same mutex, then you can make the mutex object static and pass MyResouce to MyWorkerXX as you like, as the mutex will always be the same regards Lorenzo