【发布时间】: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。
【问题讨论】:
我正在查看此示例代码 http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html
在这个例子中,为什么 pthread_self 可以在没有 pthread_create 的情况下使用?我认为一个程序需要调用 pthread_create 来创建一个 pthread,然后调用 pthread_self 来返回 pthread id。
【问题讨论】:
pthread_create 用于创建一个新的(通常是工作线程)线程。 pthread_self 用于返回调用它的线程的线程标识符。它也可以是主线程。
【讨论】: