关于Linux线程pthread_create(),pthread_join()
来源:互联网 发布:索尼软件更新 编辑:程序博客网 时间:2024/06/08 21:17
一、pthread_create()
pthread_create是类Unix操作系统(Unix、Linux、Mac OS X等)的创建线程的函数。若线程创建成功,则返回0。若线程创建失败,则返回出错编号,并且*thread中的内容是未定义的。
int
pthread_create(pthread_t *
thread
,
const
pthread_attr_t *attr,
void
*(*start_routine) (
void
*),
void
*arg);
第一个参数为指向线程标识符的指针。
第二个参数用来设置线程属性。
第三个参数是线程运行函数的起始地址。
最后一个参数是运行函数的参数
二、pthread_join()
头文件 : #include <pthread.h>
函数定义: int pthread_join(pthread_t thread, void **retval);
描述 :
pthread_join()函数,以阻塞的方式等待thread指定的线程结束。当函数返回时,被等待线程的资源被收回。如果进程已经结束,那么该函数会立即返回。并且thread指定的线程必须是joinable的。
参数 :
thread: 线程标识符,即线程ID,标识唯一线程。
retval: 用户定义的指针,用来存储被等待线程的返回值。
返回值 : 0代表成功。 失败,返回的则是错误号。
0 0
- 关于Linux线程pthread_create(),pthread_join()
- pthread_join函数、pthread_create函数及linux线程
- 线程pthread_create,pthread_join
- linux c之使用pthread_create创建线程pthread_join等待线程和pthread_exit终止线程总结
- 关于Linux 线程pthread_join的用法
- Linux 编写线程,调用pthread_create,pthread_join出现undefined reference to..问题
- linux多线程编程(pthread_join/pthread_create)
- Linux线程-pthread_join
- Linux线程之pthread_join
- 线程控制[pthread_create() pthread_join()] 线程同步[互斥锁 条件变量 信号量]
- 线程控制[pthread_create() pthread_join()] 线程同步[互斥锁 条件变量 信号量]
- 2线程原语:pthread_create(),pthread_self(),pthread_exit(),pthread_join(),pthread_cancel(),pthread_detach(
- 线程原语:pthread_create(),pthread_self(),pthread_exit(),pthread_join(),pthread_cancel(),pthread_detach(
- 关于undefined reference to `pthread_create'\`pthread_join'的问题。
- linux 创建线程pthread_create
- pthread_join函数及linux线程
- pthread_join函数及linux线程
- pthread_join函数及linux线程
- iptables 禁止端口和开放端口
- java学习
- 操作系统及ThreadX简介
- android 极光推送接入
- 怎样重建一个损坏的调用堆栈(callstack)
- 关于Linux线程pthread_create(),pthread_join()
- 周总结
- sms-2
- 利用autotools工具制作从源代码安装的软件
- 单链表
- MIUI ROM适配之旅第一天——认识Android手机2
- Hibernate实体相关的配置文件
- Hibernate4实战之Hibernate4注解零配置
- python 提取gif动态图像中的每一帧