该程序在异常处理程序被捕获之前终止
void main(){
try{
work1();
std::thread joinableThread(
[](){
work2();
}
);
work3();
throw std::runtime_error("catch me if you can");
joinableThread.join();
} catch(const std::runtime_error& ex){
std::cout << "You did it!" << std::endl;
}
}
我想处理异常处理程序,但程序在堆栈展开期间终止。我该怎么做才能确保在堆栈展开期间加入线程?