From the Boost.Thread documentation you can see that a thread object that is joinable should not be deleted, otherwise std::terminate
will be called.
So you should assure that if the thread is joinable, either join()
or detach()
should be called in the destructor of the object owning the thread. Note: if the thread itself is destroying the object, join()
is not an option. The thread would attempt to join itself, resulting in a deadlock.
However, if you keep these restrictions in mind, you can destroy a thread from within its own thread of execution.