控制程序中thread同时执行数目尝试(二)

 声明 static HANDLE       m_SignalArray[MAX_THREADCOUNT];

线程函数中,调用  DWORD SignalHandle = WaitForMultipleObjects(MAX_THREADCOUNT,  m_SignalArray ,FALSE, INFINITE);
 ::ResetEvent(m_SignalArray[SignalHandle - WAIT_OBJECT_0]);
//Do something here 

 ::SetEvent(m_SignalArray[SignalHandle - WAIT_OBJECT_0]);

 

DWORD WaitForMultipleObjects(
  DWORD nCount,
  const HANDLE* lpHandles,
  BOOL bWaitAll,
  DWORD dwMilliseconds
);

  
  
  
  
bWaitAll
[in] If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled. If FALSE, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return.

你可能感兴趣的:(thread,object,function)