您的位置:首页 > 运维架构 > Linux

linux 线程创建和结束

2016-07-07 17:50 555 查看
1.创建线程

int pthread_create(pthread_t *tidp, const pthread_attr_t *attr, (void*) (*start_rtn)(void*), void *arg);

tidp:线程标识符指针

attr:线程属性

start_rtn:运行函数的起始指针

arg:传递给运行行数的参数

2:阻塞等待线程结束

int pthread_join(pthread_t thread, void **retval);

thread:线程标识符

retval:存储被等待线程的返回值

3:非阻塞,线程正常结束退出。

pthread_detach(thread_id);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: