12131

来源:互联网 发布:软件系统推广方案 编辑:程序博客网 时间:2024/06/03 19:43
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>


void *create(void *arg)
{
    printf("new thread is created ... \n");
    return (void *)8;
}


int main(int argc,char *argv[])
{
    pthread_t tid;
    int error;
    void *temp;


    error = pthread_create(&tid, NULL, create, NULL);
    printf("main thread!\n");


    if( error )
    {
        printf("thread is not created ... \n");
        return -1;
    }
    error = pthread_join(tid, &temp);


    if( error )
    {
        printf("thread is not exit ... \n");
        return -2;
    }
    
    printf("thread is exit code %d \n", (int )temp);
    return 0;
}
0 0
原创粉丝点击