I pointed this out in a comment, but it deserves to be strengthened.
Misuse returnVal
pthread_join api a void**, void*. void*, a void** . , . , , , NULL. , undefined . , sizeof(char), , , sizeof(void*), , , . :
pthread_join(aThread[i], NULL);
, void**, void* -proc. , pthread thread-proc :
void* thread_proc(void* args)
// ^----- this is what is stashed in the pthread_join second parameter
pthread_join 0 ; .
concurrency , . . , , , .. ( , ), . , , :
pthread_t aThread[MAX_LENGTH];
int errCode[MAX_LENGTH] = {0};
for (int i = 0; i < MAX_LENGTH; i++)
{
if((errCode[i] = pthread_create(&aThread[i], NULL, &findMatch, &fpArgs)) != 0)
printf("error creating thread %d, error=%d\n", i, errCode[i]);
}
for (int i = 0; i < MAX_LENGTH; i++)
{
if(errCode[i] == 0)
{
errCode[i] = pthread_join(aThread[i], NULL))
if (errCode[i] != 0)
printf("error joining thread %d, error=%d\n", i, errCode[i]);
}
}