Linux线程pthread_attr_t 线程属性
ATTENTION:附加代码链接:
http://www.doczj.com/doc/525c4aa9c9d376eeaeaad1f34693daef5ef713ec.html/s/blog_6dc9e4cf0100xcvk.html1. 线程属性:
使用pthread_attr_t类型表示,我们需要对此结构体进行初始化,初始化后使用,使用后还要进行去除初始化!
pthread_attr_init:初始化
pthread_attr_destory:去除初始化
#include 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函数调用,将会导致其返回错误。