Reputation: 1051
I understand what both do, but I have a question about the behavior of pthread_join.
I noticed this pattern is pretty common in C (mind the pseudocode):
for i in some range:
thread[i] = pthread_create (...)
for i in some range:
pthread_join(&thread[i]...)
Why can't it happen at the same time? e.g:
for i in some range:
thread[i] = pthread_create (...)
pthread_join(&thread[i]...)
Upvotes: 0
Views: 101
Reputation: 140186
because if you do that, all threads run sequentially, since pthread_join
waits for thread termination.
So you're losing the benefit of running the threads at the same time, simply.
Upvotes: 2