multi threading

hi all
i want to do part of project with multi threading in c++
but dont know ,how pass multi argument to thread in win 32
for example in this code

myhandle = CreateThread(0, 0, mythread, 0, 0, &mythreadid);

Thanks for your help!
You could use a global variable to pass information to each individual thread. Each thread has its own ID number, so you can command each of them to do something else.
You should put all your args into a struct and pass the address of the struct. Whatever you do, don't use global variables.

And if you're using C or C++, don't use CreateThread on Windows, use _beginthreadex.
Last edited on
thank u
i want to pass a 2d dynamin alloc matrix to the thread without classes
but i dont know ,how do it with struct?
could anyone help me?
You'll need to provide specific declarations if you want specific help.

Windows questions should really be in the Windows Programming section.
Last edited on
thanks again
my problem solved

this example code:
struct myStruct{
int * val1;
IplImage *img;
float **val2;

myStruct sItem;

sItem.val2=(float **)malloc(2*sizeof(float*));
for( int i = 0; i < 2; i++ )
sItem.val2[i]=(float *) malloc(50*sizeof(float));
unsigned id;
HANDLE hThread = (HANDLE)_beginthreadex(0, 0, ThreadFunc, &sItem, 0, &id);

Topic archived. No new replies allowed.