【问题标题】:pthread_self used without pthread_createpthread_self 在没有 pthread_create 的情况下使用
【发布时间】:2015-09-11 15:47:07
【问题描述】:

我正在查看此示例代码 http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html

在这个例子中,为什么 pthread_self 可以在没有 pthread_create 的情况下使用?我认为一个程序需要调用 pthread_create 来创建一个 pthread,然后调用 pthread_self 来返回 pthread id。

【问题讨论】:

    标签: c pthreads


    【解决方案1】:

    pthread_create 用于创建一个新的(通常是工作线程)线程。 pthread_self 用于返回调用它的线程的线程标识符。它也可以是主线程

    【讨论】:

      猜你喜欢
      • 2021-10-30
      • 2010-12-09
      • 2018-03-02
      • 2019-06-20
      • 2014-10-07
      • 2018-04-08
      • 2011-10-26
      • 2018-02-13
      • 2011-03-14
      相关资源
      最近更新 更多