boost thread and process cleanup on windows

两盒软妹~` 提交于 2019-12-10 11:35:18

问题


In my program I have a static object that creates a boost::thread. The thread is supposed to run until program termination, but it shouldn't be terminated in random state, so I implemented controled thread termination in this static object's destructor. The problem is that when main() terminates my thread is terminated before the destructor is called.

Now the question: is it possible to prevent the thread to be destroyed? Or at least delay it, so that it happens after the destructor is called?


回答1:


Move the termination from the destructor to a function and simply call it before main ends.



来源:https://stackoverflow.com/questions/8001989/boost-thread-and-process-cleanup-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!