boost - C++: thread sync -
i trying synchronize 2 thread (working on same c++ map) using boost library. must tell not expert in c++ , find boost documentation quite hard understand. what want achieve, this: #thread 1 access map put in release access #thread 2 wait until map empty when it's not empty anymore, wake , gain access perform operations on 1 entry of map leave access else i tried use mutex , condition_variables, code not working properly. in specific, when thread2 waking (after waiting cond. variable), not gaining directly access map, there else got access , emptied map. therefore, got segmentation fault, because expecting map full while empty when accessed it. in addition, understand difference between mymutex.lock() , invokations boost::mutex::scoped_lock scopedlock(mutex_) ; or unique_lock . thanks teaching :) edit: here tried extract relevant parts of code. since did not understand how sync works, may not make sense... //common part boost::mutex mutex1; boost::mutex mutex2;...