多线程:pthread_exit,pthread_join,pthread_self

来源:互联网 发布:怎样在淘宝上发布宝贝 编辑:程序博客网 时间:2024/06/05 06:16
/*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;}


0 0
原创粉丝点击