线程的创建

pthread_creat函数

头文件:

  #include <pthread.h>

函数原型:

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

参数:

   thread:线程标识符指针

  attr:线程属性指针

  start_routine:线程运行函数起始地址
  arg:传递给运行函数的参数

返回值:

  0:成功

  失败返回错误编码

新创建的线程从运行函数开始运行;

线程的执行顺序是不能保证的。

posted @ 2023-02-22 21:17  踏浪而来的人  阅读(10)  评论(0编辑  收藏  举报