#include<stdio.h>#include<stdlib.h>#include<pthread.h>typedefstruct{int id;char s;}stu;pthread_t th_1;pthread_t th_2;pthread_t th_3;pthread_t th_4;
stu *first,*second;staticvoid*thread_func(void*context){
stu* ss =(stu *)context;printf("this value is %d, name is %c\n", ss->id, ss->s);}staticintthread_start(void){if(pthread_create(&th_1,NULL, thread_func, first)!=0){printf("######error#####:create thread first failed!\n");return-1;}if(pthread_create(&th_2,NULL, thread_func, second)!=0){printf("######error#####:create thread first failed!\n");return-1;}return0;}staticvoidthread_pre(void){
first =(stu *)malloc(sizeof(stu));
first->id =0;
first->s ='a';
second =(stu *)malloc(sizeof(stu));
second->id =1;
second->s ='b';}staticintpthread_exit_m(void){if(pthread_join((th_1),NULL)!=0){printf("######warning#####:exit thread first failed!\n");}if(pthread_join((th_2),NULL)!=0){printf("######warning#####:exit thread second failed!\n");}return0;}intmain(void){thread_pre();int ret =thread_start();pthread_exit_m();return0;}