您的位置:首页 > 其它

多线程应用(五)——线程操作函数

2015-08-21 17:40 197 查看
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include <process.h>
DWORD WINAPI test(void * p)
{
int i = 0;
while (++i)
{
printf("%d\n", i);
if (i > 100000)
{
ExitThread(0);//从线程内部退出
}
}

return 0;
}
void main()
{
HANDLE hd = CreateThread(NULL, 0, test, NULL, 0, NULL);

system("pause");
SuspendThread(hd);//冻结线程

system("pause");
ResumeThread(hd);//解冻线程

system("pause");
Terminate(hd);//外部退出

system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: