运行错误 terminate called without an active exception
运行错误: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相关推荐
- QT报错:“pure virtual method called; terminate called without an active exception“
QT报错:"pure virtual method called; terminate called without an active exception" 1. 错误出现 2. ...
- terminate called without an active exception错误分析
项目场景: 在使用C++中thread类创建子线程完成相关功能,并且主线程不阻塞直到子线程完成. 问题描述: 子线程的初始化在对象的初始化过程中,并且子线程有自己独立的功能,主线程并不阻塞直到子线程完 ...
- 关于 pure virtual method called terminate called without an active exception 解决方案
文章目录 一.问题描述 二.解决思路 三.解决方案 一.问题描述 因为最近在学习 C++ 并实践导师给的项目,在实践的过程中基本每天都会踩坑,今晚遇到了一个困扰了我好几个小时的问题.具体问题是当程 ...
- terminate called without an active exception异常
terminate called without an active exception异常 参考文章: (1)terminate called without an active exception ...
- terminate called without an active exception
活久见,这么多年第一次见这种异常,记录一下- 异常说明: terminate called without an active exception 异常解析: 进程被强制终止了,一般情况下,应该是子进 ...
- c++:运行错误:terminate called without an active exception
文章目录 代码 错误信息 原因 解决方法 join joinable 代码 int print() {cout << "abc"<<endl } int m ...
- linux程序报错terminate called without an active exception
程序"正常"退出时产生此错误. 1.主线程结束,子线程未结束: 2.程序中有些函数返回类型不是void,但是没写return语句: 3.其它.
- pure virtual method called terminate called without an active exception Abor
加上海思编译器的参数: g++ -mcpu=generic-armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4
- 出现运行时间错误_Excel VBA 运行错误,你知道为何突然出现错误的原因吗
我们知道在写好的某一段程序也许在运行的时候,会出现错误的提示,导致不能正常执行我们的功能.那么你可知道,这些错误的原因是什么吗?这个错误有可能是我们的语法错误,也有可能是运行错误,具体错误需要具体进行 ...
最新文章
- 2019如何学Python?这里有你需要的答案
- GridView中使用DataFromatString
- Windows核心编程 第五章 作业(下)
- python编程软件开发_Python编程对软件开发人员很重要?
- 如何解决AET field创建失败后的一系列dump
- 浅谈数据库发展史和 OceanBase 的诞生
- github+hexo搭建博客(一)
- 20191111每日一句
- idea新建一个springboot项目_SpringBoot(二):第一个Spring Boot项目
- 廖雪峰Git教程学习总结
- 手机app测试用例怎么写?手机app测试点有哪些?
- 几种常用的数据校验(异常检测)总结(3σ、肖维勒准则、狄克逊准则、格拉布斯准则、皮尔士准则、卡方检验、T检验等等)
- 研发人员如何开展职业规划
- 理解手机中的感应器模块:重力感应/光线感应/电子罗盘/陀螺仪模块功能
- 全国大学生数学建模竞赛、美赛研究生数学建模优秀论文分享
- 什么是HashMap?不同版本的HashMap有什么不同?浅谈HashMap
- 【基于可见光定位的智能超市购物车系统】(一)概览
- 秦牧鸿蒙之体有什么用,玄幻:开局奖励鸿蒙圣体
- vue Element
- 密码是6-16位字母加数字的正则表达式和验证手机号码的正则表达式