Answer the question
In order to leave comments, you need to log in
Do I need to create a separate function for each thread (_beginthread)?
I want to make two identical calculations in two threads.
I can create a universal function for the thread (Option 1) or it is better to make two separate functions for each thread (Option 2).
void Target::threadComputeXCorr(void* pParams)
{
ArgsXcorrThread * args = (ArgsXcorrThread *)pParams;
Correlation thisCorrelation = *args->correlation;
*args->xcorrAnswer = thisCorrelation.xcorr(args->serachArea);
*args->computeDone = true;
}
int main(){
...
_beginthread(threadComputeXCorr, 0, &argsA0);
_beginthread(threadComputeXCorr, 0, &argsA1);
while ((computeDoneA0 == false) or (computeDoneA1 == false));
...
}
void Target::threadComputeXCorr0(void* pParams)
{
ArgsXcorrThread * args = (ArgsXcorrThread *)pParams;
Correlation thisCorrelation = *args->correlation;
*args->xcorrAnswer = thisCorrelation.xcorr(args->serachArea);
*args->computeDone = true;
}
void Target::threadComputeXCorr1(void* pParams)
{
ArgsXcorrThread * args = (ArgsXcorrThread *)pParams;
Correlation thisCorrelation = *args->correlation;
*args->xcorrAnswer = thisCorrelation.xcorr(args->serachArea);
*args->computeDone = true;
}
int main(){
...
_beginthread(threadComputeXCorr0, 0, &argsA0);
_beginthread(threadComputeXCorr1, 0, &argsA1);
while ((computeDoneA0 == false) or (computeDoneA1 == false));
...
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question