c++11 thread

 我看我们项目创建线程从来不join,detach

#include <iostream>
#include <thread>
#include <windows.h>
#include <boost/thread/thread.hpp>
void fun()
{
    while (true)
    {
        std::cout << "hehhe" << std::endl;
    }
}
int main()
{
    std::thread th(fun);
    boost::this_thread::interruptible_wait(5000);
    TerminateProcess(GetCurrentProcess(), 0);
    return 0;
}

这个疑问很久了

终于解决了,参考这个:

http://stackoverflow.com/questions/4508181/thread-destructors-in-c0x-vs-boost

posted @ 2014-06-27 12:01  zzyoucan  阅读(182)  评论(0编辑  收藏  举报