【发布时间】:2014-12-03 03:03:48
【问题描述】:
#include <pthread.h>
void thread_routine(void*)
{
sleep(5);
pthread_detach(pthread_self());
sleep(5);
}
int main()
{
pthread_t t;
pthread_create(&t, 0, thread_routine, 0);
pthread_join(t);
}
pthread_join(t); 会在pthread_detach(pthread_self()); 成功后立即返回吗?
【问题讨论】:
-
我的猜测,就像在调用
pthread_join:UB之前线程被分离一样。
标签: c linux multithreading pthreads posix