What is the pthread's join prerequisite

112 views Asked by At

With pthread, we cannot join any thread.

What is the prerequisite and why is it there?

According to : https://man7.org/linux/man-pages/man3/pthread_join.3.html

The pthread_join() function waits for the thread specified by thread to terminate. If that thread has already terminated, then pthread_join() returns immediately. The thread specified by thread must be joinable.

1

There are 1 answers

1
Rachid K. On

The pthread_join() function makes the calling thread wait for the end of another thread (which thread identifier is passed as first parameter). By default, any thread is joinable when you call pthread_create(). If you want to make a thread non joinable, you can specify this behaviour by passing some attributes to the pthread_create() function (cf. pthread_attr_setdetachstate()).