c++11 thread

时间:2014-07-10 13:57:33   收藏:0   阅读:306

 我看我们项目创建线程从来不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

c++11 thread,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!