#include<stdio.h>
#include <pthread.h>
#include<stdlib.h>
struct Demo
{
int a;
char b;
}demo = {1, 'q'};
void *mythread()
{
printf("this is thread\n");
return ((void *)&demo);
}
int main()
{
pthread_t id1; //创建线程的标示量
int ret = pthread_create(&id1, NULL, (void*)mythread, NULL); // 创建线程
struct Demo *d;
return 0;
}
#include <pthread.h>
#include<stdlib.h>
struct Demo
{
int a;
char b;
}demo = {1, 'q'};
void *mythread()
{
printf("this is thread\n");
return ((void *)&demo);
}
int main()
{
pthread_t id1; //创建线程的标示量
int ret = pthread_create(&id1, NULL, (void*)mythread, NULL); // 创建线程
struct Demo *d;
pthread_join(id1, (void *)&d); //运行线程
printf("%d, %c", d->a, d->b);
pthread_exit(0);return 0;
}