pthread.h

pthread_create

  • int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
    void *(*start_routine)(void *), void *arg);
    • pthread_t *thread:
      指向 pthread_t 类型的指针,用于存储新创建线程的线程 ID。
    • const pthread_attr_t *attr:
      指向线程属性对象的指针,可以是 NULL,表示使用默认属性。
    • void *(*start_routine)(void *):
      线程的起始函数,这是一个函数指针,它指向一个函数,该函数接收一个 void * 类型的参数,并返回一个 void * 类型的值。
    • void *arg:
      传递给起始函数的参数。
    • 返回值
      成功返回0,否则返回错误码。