void pthread_exit(void *value)
1.0、参考
1.1、此函数的作用

终结当前线程。

如果当前线程是main函数所在线程,正在有其他线程运行的化,不会退出进程

1.2、参数说明

void *value相当于void* (*start_routine)(void*)的返回值。

1.3、使用示例
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>

/* 线程要执行的函数 */
void* run(void *args) {
    printf("running start\n");

    int sum = 0;
    for(int i = 1; i <= 100; i++) {
        sum += i;
    }

    //这里必须分配堆内存,注释释放该指针
    int *p = (int*)calloc(1, sizeof(int));
    *p = sum;

    printf("running end\n");
    return p;
}

int main() {
    pthread_t threadId;
    int rc = pthread_create(&threadId, NULL, run, NULL);
    if (0 == rc) {
        printf("create thread success\n");
        int *p;
        pthread_join(threadId, (void**)&p);
        if (NULL != p) {
            printf("p = %d\n", *p);
            free(p);
        }
        return 0;
    } else {
        printf("create thread fail!\n");
        return 1;
    }
}

使用cc命令编译:

cc -lpthread -o test_pthread test.c