• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
我是张洪铭我是熊博士
时光静好,与君同;细水长流,与君语
博客园    首页    新随笔    联系   管理    订阅  订阅

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 }

 

posted @ 2021-09-25 14:44  我是张洪铭我是熊博士  阅读(71)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3