pthread_create函数
int pthread_create((thread_t *thread,constpthread_attr_t *attr,void *(*start_routine)(void *), void *arg)
需要头文件#include <pthread.h>
功能:创建线程(实际上就是确定调用该线程函数的入口),在线程创建后就可以运行相关的线程函数。
形式参数说明:
thread:线程标识符
attr:线程属性设置;
start_routine:线程函数的起始地址
arg:传递给start_routine的参数
返回值:成功,返0,;出错返回-1.
pthread_join函数:
头文件:#include<pthread.h>
函数定义:int pthread_join(pthread_t thread, void **retval);
描述:pthread_join()函数,以阻塞的方式等待thread指定的线程结束。
当函数返回时,被等待线程的资源被收回。如果线程已结束,那么该函数会立即返回
参数:thread:线程标识符,即线程ID,标识唯一线程。
retval: 用户定义的指针,用来存储被等待线程的返回值。
返回值: 0代表成功。失败,返回的则是错误号。