I have successfully created a single thread using CreateThread().
Now I want to create 'n' number of threads but each with a different ThreadProc().
I have tried the following code but using it, 'n' number of threads are created all performing the same task (since Threadproc() function af all threads is same.)
//Start the threads
for (int i=1; i<= max_number; i++)
{
CreateThread( NULL, //Choose default security
0, //Default stack size
(LPTHREAD_START_ROUTINE)&ThreadProc,
//Routine to execute. I want this routine to be different each time as I want each thread to perform a different functionality.
(LPVOID) &i, //Thread parameter
0, //Immediately run the thread
&dwThreadId //Thread Id
)
}
Is there any way I can create 'n' number of Threads each with a different Thread procedure?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…