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.
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 callpthread_create(). If you want to make a thread non joinable, you can specify this behaviour by passing some attributes to thepthread_create()function (cf. pthread_attr_setdetachstate()).