【问题标题】:When is it safe to call pthread_attr_destroy?什么时候调用 pthread_attr_destroy 是安全的?
【发布时间】:2013-01-20 12:56:31
【问题描述】:

我在 Linux 上使用 pthread。从文档中,我不清楚在我用来创建新线程的属性上何时可以安全地调用 pthread_attr_destroy?我可以在pthread_create 返回后立即执行此操作,还是必须等到线程加入或分离?

提前致谢, 克里斯托夫

【问题讨论】:

    标签: linux pthreads detach


    【解决方案1】:

    线程属性复制到pthread_create,所以应该在pthread_create调用后销毁。

    此处需要行间阅读http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_create.html:

    如果attr指定的属性以后被修改,线程的属性不受影响。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-26
      相关资源
      最近更新 更多