摘要: 考虑一种常见情景:一个线程需要等待另一个线程完成任务才能够完成其自己的任务,该怎么办呢?有三种方案: 第一个方案:不断检查由互斥元保护的共享数据中的标识; 第二个方案:调用函数std::this_thread::sleep_for()在检查之间休眠一会儿; 第三个方案:条件变量; 条件变量 1. 当 阅读全文
posted @ 2018-01-12 14:46 SAPCE 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 献上一句名言! If all shared data is read-only, there is no problem, because the data read by one thread is unaffected by whether or not another thread is re 阅读全文
posted @ 2018-01-12 14:13 SAPCE 阅读(404) 评论(0) 推荐(0) 编辑