Create an array of thread procedures, for instance:
DWORD WINAPI myThreadProcA(LPVOID p)
{
DWORD dw = (DWORD) p;
return dw;
}
DWORD WINAPI myThreadProcB(LPVOID p)
{
DWORD dw = (DWORD)p;
return dw*dw;
}
VOID CreateMyThreads(LPTHREAD_START_ROUTINE myProc[], int max_number, HANDLE hThread[])
{
DWORD dwThreadId;
for (int i=0; i< max_number; i++)
{
hThread[i] = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)myProc[i],
(LPVOID) (i+1), 0, &dwThreadId );
}
}
Then you might call itm, for instance, this way:
const DWORD N=2;
HANDLE hThread[N];
DWORD dwExit[N];
LPTHREAD_START_ROUTINE myProc[N] = {myThreadProcA, myThreadProcB};
CreateMyThreads(myProc, N, hThread);
for (int i=0; i<N; i++)
{
do
{
GetExitCodeThread(hThread[i], &dwExit[i]);
} while (dwExit[i] == STILL_ACTIVE);
}