joinable程序崩溃
时间: 2023-11-30 19:47:36 浏览: 122
回答: 当一个线程处于joinable状态时,如果在该线程被析构之前没有调用join()或detach()函数,会导致程序崩溃。\[2\]在你提供的代码中,当程序退出时,线程t在调用join()之前被析构,因此导致了程序的崩溃。为了解决这个问题,你可以在程序退出之前调用join()函数,确保线程t正常结束。\[2\]另外,你还可以在析构函数中添加判断,如果线程处于joinable状态,则调用join()函数,以确保线程的正常结束。\[3\]
#### 引用[.reference_title]
- *1* [C++ 线程join崩溃](https://blog.csdn.net/chenFteng/article/details/79868984)[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]
- *2* [程序崩溃调试记录和总结](https://blog.csdn.net/abcbac1221/article/details/102006387)[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++ thread 使用不当导致的崩溃问题](https://blog.csdn.net/as14569852/article/details/89421365)[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 ]
阅读全文