gpt4 book ai didi

c++ - boost::thread_specific_ptr/cleanup 与 atexit 执行顺序

转载 作者:行者123 更新时间:2023-11-30 05:26:26 25 4
gpt4 key购买 nike

如果多线程应用程序被 exit(x) 或从 main 中“返回”终止——处理程序的执行顺序是什么?

  1. 由 atexit 注册的处理程序
  2. 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com