附加代码链接: http://www.linuxidc.com/Linux/2012-03/57249p3.htm
1. 线程属性:
使用pthread_attr_t类型表示,我们需要对此结构体进行初始化,
初始化后使用,使用后还要进行去除初始化!
pthread_attr_init:初始化
pthread_attr_destory:去除初始化
#include<pthread.h>
intpthread_attr_init(pthread_attr_t *attr);
intpthread_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函数调用,将会导致其返回错误。
线程属性结构如下:
typedefstruct