首页 > 代码库 > c++11 thread

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