ashfaq ashfaq - 1 year ago 112
C Question

Pthreads - Can I detach from a thread and then join in main?

What I want to do is something on lines of...

pthread_create(&producer_thread, &to_join, producer_routine, &queue);
pthread_join(producer_thread, NULL);

Is this possible in some way, on running the above code, it is unable to join the thread.

Answer Source

Once detached, it's not possible to join anymore.

From pthread_join(3) man page:

Once a thread has been detached, it can't be joined with pthread_join(3) or be made joinable again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download