linux线程随笔-pthread_create函数

函数简介

  pthread_create是UNIX环境创建线程函数

头文件

  #include<pthread.h>

函数声明

  int pthread_create(pthread_t  *restrict tidp, const  pthread_attr_t  *restrict_attr,   void*(*start_rtn)(void*),   void   *restrict   arg);

返回值

  若成功则返回0,否则返回出错编号

参数

  第一个参数为指向线程标识符的指针。

  第二个参数用来设置线程属性。

  第三个参数是线程运行函数的地址。

  最后一个参数是运行函数的参数。

注意

  在编译时注意加上-lpthread参数,以调用静态链接库。因为pthread并非Linux系统的默认库。 

猜你喜欢

转载自blog.csdn.net/andrewgithub/article/details/81812349