-
Multithreading
I have one simple question about multithreading. I do a program which will start about 30 threads at the same time. Although I can write special function for each threads, I am interested if to write the only one thread function is possible (I know - it IS possible, but I want the "errorless" and "bluescreenless" code...:) Then I start 30 threads (I use MFC, so AfxBeginThread will be called) and all threads will have the same function. Each thread will use another data, of course. Is this possible ?
-
It is possible. You simply create one Parameter Structure for each thread (or an array of those structures, so you can create threads in a loop) and then call AfxBeginThread once for each thread with the same function but different parameters.
Code:
struct PARAMS
{
int a;
int b;
}
UINT ThreadFunc(LPVOID pData);
.
.
.
PARAMS params[30];
for(... // fill all the fields
for(i=0;i<30;i++)
AfcBeginThread(ThreadFunc, params[i];
That'll do it
All the buzzt
CornedBee