详解有关线程组的操作示例
作者:asio转载自:asio分享学习快乐更新时间:2010-5-5

共享信号量类似于 读写锁
boost::shared_mutex shr_mutex;
void
 write_process() {
    shr_mutex.
lock();
    cout 
<< "begin of write_process" << endl;
    cout 
<< "end of write_process" << endl;
    shr_mutex.unlock();
}


void read_process() {
    shr_mutex.lock_shared();
    cout 
<< "begin of read_process" << endl;
    cout 
<< "end of read_process" << endl;
    shr_mutex.unlock_shared();
}


int main() {

    thread_group threads;
    
for (int i = 0; i < 10++ i) {
        threads.create_thread(
&write_process);
        threads.create_thread(
&read_process);
    }


    threads.join_all();