bool aCondition = true;
for(int i=0; i<numOfThreads; i++){
pthread_create(&firstThreads[i], NULL, &myThreads1, (void*) NULL);
if(aCondition == true)//for here, if some condition is true i want at least one thread from firstThreads to complete before any secondThreads runs
pthread_join(firstThreads[0], NULL);
pthread_create(&secondThreads[i], NULL, &myThreads2, (void*) NULL);
}
for(...)
//join the rest of the threads
return;
i have similar structure in my program, but secondThreads seems not waiting firstThreads[0] to finish.