//使用PluseEvent()函數
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <windows.h>
HANDLE g_hThreadEvent;
//快線程
unsigned int __stdcall FastThreadFun(void *pPM)
{
Sleep(10); //用這個來保證各線程調用等待函數的次序有一定的隨機性
printf("%s 啟動\n", (PSTR)pPM);
WaitForSingleObject(g_hThreadEvent, INFINITE);
printf("%s 等到事件被觸發 順利結束\n", (PSTR)pPM);
return 0;
}
//慢線程
unsigned int __stdcall SlowThreadFun(void *pPM)
{
Sleep(100);
printf("%s 啟動\n", (PSTR)pPM);
WaitForSingleObject(g_hThreadEvent, INFINITE);
printf("%s 等到事件被觸發 順利結束\n", (PSTR)pPM);
return 0;
}
int main()
{
printf(" 使用PluseEvent()函數\n");
printf("