Linux线程的几种结束方式
Linux创建线程使用int pthread_create(pthread_t *thread, const pthread_attr_t *attr,void *(*start_routine)(void *), void *arg)Linux线程的几种结束方式:调用pthread_exit(exit_code),exit_code为线程退出的状态代码。同
·
Linux创建线程使用
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
Linux线程的几种结束方式:
- 调用
pthread_exit(exit_code)
,exit_code
为线程退出的状态代码。同一进程下的其他线程可以通过pthread_join(exit_code)
来使用。 - 函数
start_routine
使用return
返回,与调用pthread_exit()
作用相同。 - 线程被取消
pthread_cancel()
。 - 同一进程中的其他线程调用了
exit()
,,或者主线程从main
函数返回。
更多推荐
已为社区贡献1条内容
所有评论(0)