如果多线程应用程序被 exit(x) 或从 main 中“返回”终止——处理程序的执行顺序是什么?
- 由 atexit 注册的处理程序
- pthread_key_create/thread_specific_ptr 清理处理程序(所谓的析构函数)
还是相反?
谢谢。
最佳答案
来自 http://www.cplusplus.com/reference/cstdlib/atexit :
If more than one atexit function has been specified by different calls to this function, they are all executed in reverse order as a stack (i.e. the last function specified is the first to be executed at exit).
关于c++ - boost::thread_specific_ptr/cleanup 与 atexit 执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37784616/