运行错误:terminate called without an active exception,可能的原因 :下面的代码中的

t41.join();
        t42.join();
        t43.join();

注释掉会出现这个错误

#include "stdio.h"
#include <iostream>
#include <thread>int main(int argc, char **argv){std::thread t1([](){while(true){std::this_thread::sleep_for(std::chrono::seconds(1));printf(" t1 t1 t1 t1 ------------------------------------- \n");}});std::thread t2([](){while(true){std::this_thread::sleep_for(std::chrono::seconds(1));printf(" t2 t2 t2 t2 ------------------------------------- \n");}});std::thread t3([](){while(true){std::this_thread::sleep_for(std::chrono::seconds(1));printf(" t3 t3 t3 t3 ------------------------------------- \n");}});std::thread t4([](){std::thread t41([](){while(true){std::this_thread::sleep_for(std::chrono::seconds(1));printf(" t41 ------------------------------------- \n");}});std::thread t42([](){while(true){std::this_thread::sleep_for(std::chrono::seconds(1));printf(" t42 ------------------------------------- \n");}});std::thread t43([](){while(true){std::this_thread::sleep_for(std::chrono::seconds(1));printf(" t43 ------------------------------------- \n");}});t41.join();t42.join();t43.join();});t1.join();t2.join();t3.join();t4.join();return -1;
}

输出:

t41 ------------------------------------- 
 t1 t1 t1 t1 ------------------------------------- 
 t2 t2 t2 t2 ------------------------------------- 
 t3 t3 t3 t3 ------------------------------------- 
 t42 ------------------------------------- 
 t43 ------------------------------------- 
 t1 t1 t1 t1 ------------------------------------- 
 t41 ------------------------------------- 
 t2 t2 t2 t2 ------------------------------------- 
 t3 t3 t3 t3 ------------------------------------- 
 t42 ------------------------------------- 
 t43 ------------------------------------- 
 t1 t1 t1 t1 ------------------------------------- 
 t3 t3 t3 t3 ------------------------------------- 
 t42 ------------------------------------- 
 t43 ------------------------------------- 
 t41 ------------------------------------- 
 t2 t2 t2 t2 -------------------------------------

线程中嵌套线程,好玩。 ps:CMAKE_CXX_STANDARD 11

运行错误 terminate called without an active exception相关推荐

  1. QT报错:“pure virtual method called; terminate called without an active exception“

    QT报错:"pure virtual method called; terminate called without an active exception" 1. 错误出现 2. ...

  2. terminate called without an active exception错误分析

    项目场景: 在使用C++中thread类创建子线程完成相关功能,并且主线程不阻塞直到子线程完成. 问题描述: 子线程的初始化在对象的初始化过程中,并且子线程有自己独立的功能,主线程并不阻塞直到子线程完 ...

  3. 关于 pure virtual method called terminate called without an active exception 解决方案

    文章目录 一.问题描述 二.解决思路 三.解决方案 一.问题描述   因为最近在学习 C++ 并实践导师给的项目,在实践的过程中基本每天都会踩坑,今晚遇到了一个困扰了我好几个小时的问题.具体问题是当程 ...

  4. terminate called without an active exception异常

    terminate called without an active exception异常 参考文章: (1)terminate called without an active exception ...

  5. terminate called without an active exception

    活久见,这么多年第一次见这种异常,记录一下- 异常说明: terminate called without an active exception 异常解析: 进程被强制终止了,一般情况下,应该是子进 ...

  6. c++:运行错误:terminate called without an active exception

    文章目录 代码 错误信息 原因 解决方法 join joinable 代码 int print() {cout << "abc"<<endl } int m ...

  7. linux程序报错terminate called without an active exception

    程序"正常"退出时产生此错误. 1.主线程结束,子线程未结束: 2.程序中有些函数返回类型不是void,但是没写return语句: 3.其它.

  8. pure virtual method called terminate called without an active exception Abor

    加上海思编译器的参数: g++ -mcpu=generic-armv7-a  -mfloat-abi=softfp  -mfpu=neon-vfpv4

  9. 出现运行时间错误_Excel VBA 运行错误,你知道为何突然出现错误的原因吗

    我们知道在写好的某一段程序也许在运行的时候,会出现错误的提示,导致不能正常执行我们的功能.那么你可知道,这些错误的原因是什么吗?这个错误有可能是我们的语法错误,也有可能是运行错误,具体错误需要具体进行 ...

最新文章

  1. 2019如何学Python?这里有你需要的答案
  2. GridView中使用DataFromatString
  3. Windows核心编程 第五章 作业(下)
  4. python编程软件开发_Python编程对软件开发人员很重要?
  5. 如何解决AET field创建失败后的一系列dump
  6. 浅谈数据库发展史和 OceanBase 的诞生
  7. github+hexo搭建博客(一)
  8. 20191111每日一句
  9. idea新建一个springboot项目_SpringBoot(二):第一个Spring Boot项目
  10. 廖雪峰Git教程学习总结
  11. 手机app测试用例怎么写?手机app测试点有哪些?
  12. 几种常用的数据校验(异常检测)总结(3σ、肖维勒准则、狄克逊准则、格拉布斯准则、皮尔士准则、卡方检验、T检验等等)
  13. 研发人员如何开展职业规划
  14. 理解手机中的感应器模块:重力感应/光线感应/电子罗盘/陀螺仪模块功能
  15. 全国大学生数学建模竞赛、美赛研究生数学建模优秀论文分享
  16. 什么是HashMap?不同版本的HashMap有什么不同?浅谈HashMap
  17. 【基于可见光定位的智能超市购物车系统】(一)概览
  18. 秦牧鸿蒙之体有什么用,玄幻:开局奖励鸿蒙圣体
  19. vue Element
  20. 密码是6-16位字母加数字的正则表达式和验证手机号码的正则表达式

热门文章

  1. 三国杀开源系列之二105@365
  2. Container is running beyond physical memory limits
  3. 论运维职业发展中的自我修养
  4. SEO优化:用SEO常用表格的原因,为什么要行使seo表格器材
  5. 在线快速提取QQ群成员的QQ号码方法(无需软件操作)
  6. ios 图片缩放,等比例压缩
  7. 新生代小鲜肉之代码生成器
  8. 酒店智能门锁方案功能及其特点介绍
  9. 小白如何购买阿里云服务器(图文教程)
  10. 麦肯锡七步成诗法学习笔记简记以及案例分析(附参考资料可下载)