关于线程ctrl+c终止的问题

worldcup worldcup 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
DWORD WINAPI AThread(LPVOID lparam)
{
while(1)
{
.....//没有任何退出条件,只是循环等待
}

funA();
return 0;
}

CreateThread(NULL,NULL,AThread,(LPVOID)argu,0,&threadId);


主程序启动线程AThread()后处于等待状态,我用ctrl+c强制退出,线程AThread也就退出了,
不执行funA(),但我还想在ctrl+c后运行其中的funA();请问该如何实现,谢谢!!


...全文

相关推荐

Python中用Ctrl+C终止多线程程序的问题解决

复制代码 代码如下:#!/bin/env python # -*- coding: utf-8 -*- #filename: peartest.py import threading, signal is_exit = False def doStress(i, cc):     global is_exit     idx = i     while not is_exit:         if (idx < 10000000):             print “thread[%d]: idx=%d”%(i, idx)             idx = idx + cc      

weixin_38546817

探寻python多线程ctrl+c退出问题解决方案

场景: 经常会遇到下述问题:很多io busy的应用采取多线程的方式来解决,但这时候会发现python命令行不响应ctrl-c 了,而对应的java代码则没有问题: 复制代码 代码如下: public class Test {      public static void main(String[] args) throws Exception {            new Thread(new Runnable() {                public void run() {                  long start = System.curren

weixin_38701725

C语言如何正确的终止正在运行的子线程

主要介绍了C语言如何正确的终止正在运行的子线程,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

weixin_38688745

python子线程退出及线程退出控制的代码

下面通过代码给大家介绍python子线程退出问题,具体内容如下所示: def thread_func(): while True: #do something #do something #do something t=threading.Thread(target = thread_func) t.start() # main thread do something # main thread do something # main thread do something 跑起来是没有问题的,但是使用ctrl + c中断的时候出问题了,主线程退出了,

等到风景都看透⊙∀⊙?

weblogic jms c程序

I am working with BEA-JMS C API in my project. Here I am having one main() function thread and one onMessage thead for continous message handling... I am using Signal handling for stoping my application(Ctrl-c)..Signal handling is working in main() function.The problem comes when I stop the application using ctrl-c...When I press ctrl-c , the function signal_handling is not receiving the signal.Some internal thread is abrubly stop and the whole aplication stop without any futher execution in main function.

attitude2002
评论 10
收藏 已收藏
分享
返回顶部
worldcup
进程/线程/DLL 15,466 成员 49,169 内容