1、等待子线程退出的思路1)主线程中,使用pthread_create创建子线程2)主线程中,使用pthread_join等待子线程退出
2、pthread_create的语法形式类库:#include <pthread.h>原型:int pthread_create(pthread_t * t茑霁酌绡hread, const pthread_attr_t * attr, void * (*start_routine)(void*)), void * arg);参数:thread -> 线程IDattr -> 线程属性start_routine -> 线程函数arg -> 线程入参
3、pthread_join的语法形式亿姣灵秀类库:#include <pthread.h>原型:int pthread_join(pthread_t thread, void **r髫潋啜缅etval);参数:thread ->线程IDretval ->线程推出返回值
4、创建子线程,等待子线程退出命令:[root]#touch main.cpp[root]#vi main.cpp

5、编译备注:编译需要链接pthread库。
