boost线程和进程清理在windows上 [英] boost thread and process cleanup on windows
问题描述
在我的程序中,我有一个静态对象,创建一个boost :: thread。线程应该运行,直到程序终止,但它不应该终止在随机状态,所以我实现了控制线程终止在这个静态对象的析构函数。问题是,当main()终止时,我的线程在调用析构函数之前被终止。
现在的问题是:是否可以防止线程被销毁?将析构函数的终结点移动到函数并在主要结束前简单调用它。
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?
Move the termination from the destructor to a function and simply call it before main ends.
这篇关于boost线程和进程清理在windows上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!