#include <stdio.h>
#include <pthread.h>
#include <malloc.h>
typedef struct st
{
int key;
char *val;
}ST;
void *f(void *arg)
{
return arg;
}
int main()
{
pthread_t t;
ST *s = (ST*)malloc(sizeof(ST));
s->key = 1;
s->val = "val";
pthread_create(&t, NULL, (void*)f, (void*)s);
ST *ret;
pthread_join(t, (void*)&ret); // ret为已终止线程的退出状态
printf("%d %s\n", ret->key, ret->val);
return 0;
}
Linux线程---线程结束返回一个复杂的数据结构
最新推荐文章于 2023-07-15 23:56:35 发布