std::get<C++11多线程库>(01): hello C++ 并发世界

 1 #include <QCoreApplication>
 2 #include <iostream>
 3 #include <thread>
 4 
 5 //int main(int argc, char *argv[])
 6 //{
 7 //    QCoreApplication a(argc, argv);
 8 //    std::cout<<"hello word "<<std::endl;
 9 //    return a.exec();
10 //}
11 
12 
13 void hello(){
14     std::cout<<"hello word "<<std::endl;
15 }
16 
17 int main(int argc, char *argv[])
18 {
19     QCoreApplication a(argc, argv);
20 
21     std::thread t(hello); // thread t 对象 关联着新线程
22     t.join();  //让初始线程等待新线程执行结束
23     return a.exec();
24 }
原文地址:https://www.cnblogs.com/azbane/p/15334358.html