Jun 30, 2012 at 7:26am UTC
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!
Jun 30, 2012 at 12:02pm UTC
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.
Jun 30, 2012 at 12:42pm UTC
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 Jun 30, 2012 at 12:46pm UTC
Jun 30, 2012 at 4:04pm UTC
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?
Jun 30, 2012 at 4:07pm UTC
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 Jun 30, 2012 at 4:08pm UTC
Jun 30, 2012 at 4:55pm UTC
hi
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));