EXITTHRD.C--示范ExitThread()
来源:互联网 发布:数据增值服务内容 编辑:程序博客网 时间:2024/06/08 06:14
#define WIN32_LEAN_AND_MEAN
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
DWORD WINAPI ThreadFunc(LPVOID);
void AnotherFunc(void);
int main()
{
HANDLE hThrd;
DWORD exitCode = 0;
DWORD threadId;
hThrd = CreateThread(NULL, 0, ThreadFunc, (LPVOID)1, 0, &threadId);
if (hThrd)
printf("Thread launched\n");
for (;;)
{
BOOL rc;
rc = GetExitCodeThread(hThrd, &exitCode);
if (rc && exitCode != STILL_ACTIVE)
break;
}
CloseHandle(hThrd);
printf("Thread returned %d \n", exitCode);
return EXIT_SUCCESS;
}
/*Call a function to do something that terminates the thread
with ExitThread instead of returning*/
DWORD WINAPI ThreadFunc(LPVOID n)
{
printf("Thread running\n");
AnotherFunc();
return 0;
}
void AnotherFunc()
{
printf("About to exit thread\n");
ExitThread(4);
//it is impossible to get here, this line will never be printed
printf("This will never print\n");
}
- EXITTHRD.C--示范ExitThread()
- ExitThread()
- ExitThread
- ExitThread
- C 冒泡排序原理示范
- LINUX下c语言SOCKET客户端示范
- exitcode.c---示范GetExitCodeThread()的用法
- C的简单文件读写示范
- (转载)LINUX下c语言SOCKET客户端示范
- 一个简单用c和mysql的示范程序
- CloseHandle()和ExitThread()区别
- 调用CloseHandle和 ExitThread
- GetExitCodeThread() 和 ExitThread()
- ExitThread function学习
- Win32多线程之ExitThread
- _beginthread, _endthread, CreateThread, ExitThread
- 示范文章
- 错误示范
- 收集常用的.net开源项目
- leetCode 83.Remove Duplicates from Sorted List(删除排序链表的重复) 解题思路和方法
- 提升linux下tcp服务器并发连接数限制
- java中的开方Math.sqrt(n)函数和平方{a的b次方Math.pow(a, b)}
- 图片折叠效果:Layer的contentsRect属性和渐变层
- EXITTHRD.C--示范ExitThread()
- oracle 数据汞导入导出dmp文件
- AutoLayout
- 百度推送之Im
- leetCode 84.Largest Rectangle in Histogram (最大矩形直方图) 解题思路和方法
- Linux Shell编程学习笔记(2)
- linux的共享中断机制
- 互联网+农业电商
- Redhat7/Centos7 安装配置 RabbitMQ