0

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.

wazowski
  • 115
  • 8

1 Answers1

2

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()).

Rachid K.
  • 4,490
  • 3
  • 11
  • 30