If I have multiple threads and I would like to wait for a thread to finish, why is this undefined according to the pthread_join() function?
For example, the code below shows thread 1 and 2 wait for thread 0:
void* thread1(void* t1){
..
pthread_join(pthread_t thread0, void **retval1);
return NULL
}
void* thread2(void* t2){
..
pthread_join(pthread_t thread0, void **retval2);
return NULL
}
Why would this behaviour be undefined or in other words not possible?
A1 and A2orA1 or A2. You have to wait onA1and then wait onA2, which is a bit of a hassle if you don't know up from which one will finish first. In comparison, Windows hasWaitForMultipleObjects. This is far more flexible. - MSalters