ATTENTION:附加代码链接:
http://blog.sina.com.cn/s/blog_6dc9e4cf0100xcvk.html
1. 线程属性:
使用pthread_attr_t类型表示,我们需要对此结构体进行初始化,
初始化后使用,使用后还要进行去除初始化!
pthread_attr_init:初始化
pthread_attr_destory:去除初始化
#include <pthread.h>
int pthread_attr_init(pthread_attr_t *attr);
int pthread_attr_destroy(pthread_attr_t *attr);
若成功返回0,若失败返回-1。
pthread_attr_init之后,pthread_t结构所包含的内容就是操作系统实现
支持的线程所有属性的默认值。
如果pthread_attr_init实现时为属性对象分配了动态内存空间,
pthread_attr_destroy还会用无效的值初始化属性对象,因此如果经
pthread_attr_destroy去除初始化之后的pthread_attr_t结构被
pthread_create函数调用,将会导致其返回错误。
线程属性结构如下:
typedef struct
|