关于thread不能被try catch
生活随笔
收集整理的這篇文章主要介紹了
关于thread不能被try catch
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include <iostream>
#include <thread>
int main()
{
?? ?try {
?? ??? ?//子線程不能拋異常
?? ??? ?std::thread t([&]() {
?? ??? ??? ?while (1){
?? ??? ??? ??? ?std::this_thread::sleep_for(std::chrono::seconds(1));
?? ??? ??? ?}
?? ??? ??? ?});
?? ?}
?? ?catch (...) {
?? ?}
?? ?while (1) {
?? ??? ?std::this_thread::sleep_for(std::chrono::seconds(1));
?? ?}
}
結論:try catch 不能 捕獲thread 異常。呵呵噠,直接刷新我的世界觀
總結
以上是生活随笔為你收集整理的关于thread不能被try catch的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vue.js使用矢量图
- 下一篇: Openshift3.9部署手册