为什么,天空是蓝色,为什么,大地是黑色,为什么,血是红色,为什么,这段代码无法返回....
HANDLE hSemaphore;
int iThread=100;
UINT myfunction()
{
HANDLE hThread=NULL;
DWORD dwThreadID;
long PreviousCount;
hSemaphore=CreateSemaphore(NULL,iThread,iThread,NULL);
if(hSemaphore==NULL)
{
//("CreateSemaphore failed:%d",GetLastError());
}
for(int i=0;i<=iThread;i++)
{
hThread=CreateThread(NULL,0,ThreadPro,NULL,0,&dwThreadID);
if(hThread==NULL)
{
//("Create thread failed");
break;
}
CloseHandle(hThread);
WaitForSingleObject(hSemaphore,INFINITE);
}
while(1)
{
WaitForSingleObject(hSemaphore,INFINITE);
if(!ReleaseSemaphore(hSemaphore,1,&PreviousCount))
{
//("\nReleaseSemaphore failed:%d",GetLastError());
break;
}
if(PreviousCount==(iThread-1))
{
//("全部完毕");
break;
}
}
CloseHandle(hSemaphore);
return 0;
}
就是没法返回 0