线性的创建
pthread_create函数
函数的作用:创建线程
表头文件:#include <pthread.h>
函数原型:int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*start_rtn)(void), void *restrict arg)
函数参数:*restrict tidp要创建的线程ID指针
*restrict attr创建线程时的线程属性
void*(start_rtn)(void):返回值是void类型的指针函数
void *restrict arg:start——rtn的形参
返回值:成功返回0,其他值表示错误
pthread_exit
函数的作用:终止线程
表头文件:#include <pthread.h>
函数的原型:void pthread_exit(void *retval)
返回值:调用线程的返回值
pthread_join
函数作用:等待线程
表头文件:#include<pthread.h>
函数原型:int pthread_join(thread_t tid, void **status)
函数参数:tid:要等待的线程ID,status线程状态
返回值:成功返回0.其他白哦是错误