pthread_exit的参数是一个指向线程的退出状态的指针。 pthread_exit函数的原型如下: ```c void pthread_exit(void *retval); ``` 参数retval是指向线程退出状态的指针。该状态可以被其他线程通过pthread_join函数获取。pthread_exit函数会阻塞当前线程,直到其他线程调用pthread_join函数或者主线程结束。如果当前线程是...
pthread_exit((void *)&foo);//线程返回值存在foo,栈中,该函数结束释放 } void * thr_fn2(void *arg) { printf("thread 2:ID is %d\n",pthread_self()); pthread_exit((void *)0); } int main(void) { int err; pthread_t tid1,tid2; struct foo *fp; err=pthread_create(&tid1,NULL,t...
include <stdio.h>#include <stdlib.h>#include <pthread.h>void *print_message_function( void *ptr ){char *message;message = (char *) ptr;printf(%s \t, message);printf(PID: %ld \n, pthread_self());pthread_exit (thread all done); // 重点看 pthread_exit() 的参数,是一...
pthread_exit((void *)&foo);//线程返回值存在foo,栈中,该函数结束释放 } void * thr_fn2(void *arg) { printf("thread 2:ID is %d\n",pthread_self()); pthread_exit((void *)0); } int main(void) { int err; pthread_t tid1,tid2; struct foo *fp; err=pthread_create(&tid1,NULL,t...