首页 > linux pthread_create

linux pthread_create

int pthread_create(pthread_t *thread, const pthread_attr_t *attr, 
                    void *(*start_routine) (void *), void* arg);

Linux中创建线程用这个函数,用man命令查询该函数得知,当创建线程成功时,*thread 存储着线程id.
如果创建线程失败,*thread中的内容未定义。这个未定义是什么意思???
如果调用该函数之前,已经为*thread赋了值,创建线程失败后,*thread的值会被改变吗?
还请有了解解释一番 谢谢了。。。


未定义就是如果失败了, POSIX没有明确定义*thread会是什么值, 具体值依赖具体的API实现而不同, 但是不管值是什么, 你都不应该在失败后使用这个值.

【热门文章】
【热门文章】