Try this:
DWORD WINAPI ThreadProc1( LPVOID lpParameter)
{
...
return 0 ;
}
DWORD WINAPI ThreadProc2( LPVOID lpParameter)
{
...
return 0 ;
}
...
typedef DWORD (WINAPI * THREADPROCFN)(LPVOID lpParameter);
THREADPROCFN fntable[4] = {ThreadProc1, ThreadProc2, ...} ;
//Start the threads
for (int i = 0; i < max_number; i++)
{
DWORD ThreadId ;
CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE)fntable[i],
(LPVOID) i,
0,
&ThreadId
) ;
}
This will start max_number threads with different thread procedures (TreadProc1, ThreadProc2, etc.) as defined in fntable.
6
solved How to create multiplethreads each with different ThreadProc() function using CreateThread()