std ::mutex
时间: 2023-08-19 21:11:52 浏览: 172
std::mutex是一种独占的互斥量,不能递归使用,也不带超时功能。它是C++标准库中用于实现线程同步的一种基本锁机制。当一个线程对std::mutex对象进行上锁后,其他线程将无法再对该对象进行上锁,直到该线程释放了锁。这样可以确保在同一时间只有一个线程能够访问被保护的共享资源,从而避免了数据竞争和并发访问的问题。\[3\]
#### 引用[.reference_title]
- *1* *2* [C++11 并发指南三(std::mutex 详解)](https://blog.csdn.net/weixin_34362875/article/details/86403149)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [【C++】11新特性:std::thread、std::mutex和两种RAII方式的锁封装](https://blog.csdn.net/qq_41950508/article/details/126678834)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文