What I want to do is something on lines of...
pthread_create(&producer_thread, &to_join, producer_routine, &queue);
pthread_detach(producer_thread);
...
...
pthread_join(producer_thread, NULL);
Is this possible in some way, on running the above code, it is unable to join the thread.
Once detached, it's not possible to join anymore.
From Notes on pthread_detach()
's man page:
Once a thread has been detached, it can't be joined with
pthread_join(3)
or be made joinable again.