执行结果
ret=22
task1
task2
ret=0
第一个phread_join() 没有等待直接返回了
第二个phread_join() 等待,从返回值看执行成功了。
请大家帮忙看看作者: berniechen 时间: 2008-09-11 22:45
我两个线程分别用pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)和pthread_detach(pthread_self())来使线程达到detach状态。
怎么第二种不好使。是我的用法有问题还是理解的不对作者: ynchnluiti 时间: 2008-09-11 23:21
After pthread_detach completes, subsequent attempts to perform
pthread_join on th will fail. If another thread is already joining the
thread th at the time pthread_detach is called, pthread_detach does
nothing and leaves th in the joinable state.