Pthreads - 我可以从线程分离然后加入主线程吗?

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

我想做的是……

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

这是否可能以某种方式实现,在运行上面的代码中,它无法加入线程。

分离后,将无法再加入。

来自注释 pthread_detach() 的手册页:

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