4 Thread joining in Linux
4 Thread joining in Linux Program which contain in the post this and this main doesnt wait for thread finishes their work. We can make the main thread wait for the child thread to finish their work with the help of thread join mechanism. We need to set thread as joinable by using thread attribute. API used for thread join : int pthread_attr_init ( pthread_attr_t * attr ) ; This API used to init thread attribute. Pass pthread_attr_t type variable as argument. int pthread_attr_setdetachstate ( pthread_attr_t * attr , int detachstate ) ; Here only we need to set the properties of attribute variable. First argument is pthread_attr_t type variable and second argument is state. There is two type of state PTHREAD_CREATE_DETACHED - Threads that are created using attr will be created in a detached state. PTHREAD_CREATE_JOINABLE - Threads that are created using attr...