What’s the best way to delete boost::thread object right after its work is complete?

Viewed 16041

I create boost::thread object with a new operator and continue without waiting this thread to finish its work:

void do_work()
{
    // perform some i/o work
}

boost::thread *thread = new boost::thread(&do_work);

I guess, it’s necessary to delete thread when the work is done. What’s the best way to this without explicitly waiting for thread termination?

4 Answers
Related