boost thread and process cleanup on windows

2019-05-30 10:15发布

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条回答
Luminary・发光体
2楼-- · 2019-05-30 10:53

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

查看更多
登录 后发表回答