???????
???????pthread????Linux????????????POSIX??????Linux?н??????????????????????? -lpthread????-pthread?????????????
????$g++ main.cpp -lpthread -o main
????$./main
????????pthread_join????
????????????
????int pthread_join(pthread_t thread?? void **retval);
???????????
????thread: ??????????????ID?????????
????retval: ????????????????洢???????????????
????????
????pthread_join???????????????????У?????thread????????????????????????????????????????????????????????????????ú??????????????????thread?????????????joinable????′?????????????joinable???
????????????????????joinable????????detached
????joinable???????????????????????????????????????????洢?????????????????detached????????????????????????洢????????????????
?????????????£??????joinable?????е?pthread_join???????????????????????????????????????????????????detached?????б???????????????????????????????????
??????????????????pthread_attr_setdetachstate???????????pthread_attr_setdetachstate(pthread_attr_t* attr?? int detachstate);???е??????????????PTHREAD_CREATE_DETACHED???????????? PTHREAD _CREATE_JOINABLE?????????????
?????????????????????????????????????????????????????pthread_create????????????????????????????????????????????????????????????????pthread_create????????????????????????????????????????????????????????????????????????????????pthread_cond_timewait?????????????????????????????????ú???pthread_create???????????ε???????????????????????????????????????? wait ????????????????????????????????????????????????
????????????е????????????pthread_detach(th)????th????????DETACHED?????????th??????????????????????????????????????????pthread_join()?????pthread_detach()????????th????pthread_join()?????????
???????linux??????????????
????attr?????????
????pthread_attr_t attr;
 

?????????????

 

pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_init ???????????0???????κη?????????????????????????????????

????????????
???????  pthread_attr_destroy(&attr) ???????????????洢??????????????Ч?????????????????0???????κη?????????????????????????????????