【问题标题】:Is the first argument to pthread_create function a thread handlerpthread_create 函数的第一个参数是线程处理程序吗
【发布时间】:2020-12-11 12:11:15
【问题描述】:

Linux 手册页将 pthread_create 函数定义为

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

这个指向 pthread_t 的指针是做什么用的?我们可以说它是一个线程处理程序吗?

【问题讨论】:

  • 如果有的话,它是指向存储线程 handle 的变量的指针,而不是 handler

标签: c pthreads


【解决方案1】:

来自manpage of pthread_create

有关pthread_create()*thread 返回的线程 ID 的更多信息,请参阅pthread_self(3)

你也可以称它为句柄(不是处理程序)。

您可以将该 ID 用于pthread_join

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多