64,676
社区成员
发帖
与我相关
我的任务
分享
# include <windows.h>
# include <stdio.h>
int iCount = 0;
HANDLE hEventArray[10];
DWORD WINAPI ListenThread(LPVOID lpParameter)
{
int iIndex;
iIndex = WaitForMultipleObjects(iCount, hEventArray, FALSE, INFINITE);
printf("%d\n", iIndex);
SetEvent(hEventArray[iIndex]);
return 0;
}
int main()
{
HANDLE hThread;
while(iCount < 10)
{
hEventArray[iCount] = CreateEvent(NULL, FALSE, TRUE, NULL);
iCount++;
hThread = CreateThread(NULL, 0, ListenThread, NULL, 0, NULL);
CloseHandle(hThread);
}
Sleep(4000);
return 0;
}
# include <windows.h>
# include <stdio.h>
int iCount = 0;
HANDLE hEventArray[10];
DWORD WINAPI ListenThread(LPVOID lpParameter)
{
int iIndex;
iIndex = WaitForMultipleObjects(iCount, hEventArray, FALSE, INFINITE);
printf("%d\n", iIndex);
SetEvent(hEventArray[iIndex]);
return 0;
}
int main()
{
HANDLE hThread;
while(iCount < 10)
{
hEventArray[iCount] = CreateEvent(NULL, FALSE, TRUE, NULL);
iCount++;
}
hThread = CreateThread(NULL, 0, ListenThread, NULL, 0, NULL);
CloseHandle(hThread);
Sleep(4000);
return 0;
}