I'm trying to implement a multithreaded application but got some doubts. Can anybody please clarify one this?
My main goal is to
- Create five threads to execute the work concurrently.
The program for this is:
for(i = 0; i < 5; i++)
{
pthread_create(tid[i], NULL, func, NULL)
}
Then generally we call for the pthread_join():
for(j = 0; j < 5; j++)
{
pthread_join(tid[j], NULL);
}
So here my question is that in this call of pthread_join(), if thread 2 finishes first then thread 2 will wait for thread 1 to finish as we have put in a sequential loop for the pthread_join() function.
if thread 2 finishes first then thread 2 will wait for thread 1 to finish as we have put in a sequential loop for the pthread_join function?