/*exit_join_id.c*/
#include<pthread.h>
#include<stdio.h>
void* eji(void* agr)
{
printf("here is eji\n");
printf("PID= %u",(unsigned int)pthread_self());
pthread_exit("here all done!\n");
}
int main(int argc, char** argv)
{
pthread_t pid;
int ret;
void* j_ret;
ret=pthread_create(&pid,NULL,eji,NULL);
if(ret)
{
printf("pthread_create failed\n");
return -1;
}
ret=pthread_join(pid,&j_ret);
if(ret)
{
printf("pthread_join failed \n");
return -1;
}
printf("the return value is %s",(char*)j_ret);
return 0;
}
多线程:pthread_exit,pthread_join,pthread_self
最新推荐文章于 2023-03-10 16:18:15 发布