C++11-thread(join detach joinable)

#include <iostream>
#include <thread> //c++11中 thread的頭文件 C++11中的很多函數都放到了std庫裏面

void testThread()
{
   std::cout << "this is funciton: " << __func__ << std::endl;
}
int main()
{
    std::cout << "first function: "<<__func__ << std::endl;
    std::thread th1(testThread);
    th1.join();
    std::cout << __func__ << " end" << std::endl;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章