多线程:pthread_exit,pthread_join,pthread_self

/*exit_join_id.c*/

#include<pthread.h>
#include<stdio.h>

void* eji(void* agr)
{
    printf("here is eji
");
    printf("PID= %u",(unsigned int)pthread_self());
    pthread_exit("here all done!
");
}

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
");
	return -1;
    }
    ret=pthread_join(pid,&j_ret);

    if(ret)
    {
        printf("pthread_join failed 
");
	return -1;
    }

    printf("the return value is %s",(char*)j_ret);
    return 0;
}


原文地址:https://www.cnblogs.com/bzyzhang/p/5399636.html