标签:void sign suspend 自己 resume 邮件发送 线程调度 while 实现
#include <stdio.h> #include <process.h> #include <Windows.h> class CUser { public: HANDLE m_hThr; void Suppend() { SuspendThread(m_hThr); } }; unsigned _stdcall ThrTest(VOID* pPara) { CUser* p = (CUser*)pPara; int a = 0; while(1) { printf("Send email success -> %d\n", ++a); // 自陷如暂停状态 p->Suppend(); } return 0; } int main() { CUser* p = new CUser(); // 创建发邮件线程,创建时挂起 p->m_hThr = (HANDLE)_beginthreadex(NULL, 0, ThrTest, p, CREATE_SUSPENDED, NULL); while(1) { // 须要启动线程 ResumeThread(p->m_hThr); Sleep(1500); } CloseHandle(p->m_hThr); delete p; p = NULL; return 0; }
标签:void sign suspend 自己 resume 邮件发送 线程调度 while 实现
原文地址:http://www.cnblogs.com/jhcelue/p/6732771.html