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

后端 未结 4 748
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 16:43

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

void do_work()
{
            


        
4条回答
  •  猫巷女王i
    2020-12-06 17:23

    I suggest you use boost::shared_ptr, so you won't take care when to delete thread object.

    boost::shared_ptr thread(new boost::thread(&do_work));
    

提交回复
热议问题