线程操作:冻结与解冻线程

来源:互联网 发布:怎么选苹果笔记本 知乎 编辑:程序博客网 时间:2024/05/17 00:04
DWORD WINAPI fun(void *p){int i = 0;while (++i){printf("\n%d", i);if (i>8000){ExitThread(0);}Sleep(500);}return 0;}//主线程,主导作用,管理调用其他线程void main(){HANDLE hd = CreateThread(NULL, 0, fun, NULL, 0, NULL);system("pause");SuspendThread(hd);//冻结system("pause");ResumeThread(hd);//解冻system("pause");TerminateThread(hd,0);system("pause");}

0 0
原创粉丝点击