【发布时间】:2017-08-18 18:30:30
【问题描述】:
除了 pthread_attr_t 之外,来自 POSIX 线程的 pthread_create 的所有参数都非常易于理解。 pthread_attr_t 的用途是什么,如何以及何时不应该由 NULL 初始化?
我浏览了 Linux man page。我找到的关于 pthread_attr_t 的描述是:
-
语法:
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void*),void *arg); -
解释:
The attr argument points to a pthread_attr_t structure whose contents are used at thread creation time to determine attributes for the new thread; this structure is initialized using pthread_attr_init(3) and related functions. If attr is NULL, then the thread is created with default attributes.
这是非常不清楚的。我还在互联网上搜索了整个互联网,也没有在任何地方找到明确的解释。那么,当 pthread_attr_t 不是 NULL 时?
有人可以解释一下吗?非常感谢所有 cmets 和反馈。
【问题讨论】:
标签: c multithreading arguments pthreads posix