日期:2014-05-16 浏览次数:20735 次
#include<stdio.h>
#include<pthread.h>
int num1,num2;
void * mythread(* attr)
{
int * num=(int *)attr;
printf("%d \n",*num);
}
int main(int agrc,char *argv[])
{
pthread_t tid1,tid2;
int status;
num1 = 1;
num2 = 2;
status = pthread_create(&tid1,NULL,mythread,&num1);
if(status){
printf("create failed!");
return -1;
}
status = pthread_create(&tid2,NULL,mythread,&num2);
if(status){
printf("create failed!");
return -1;
}
status = pthread_join(tid1,NULL);
if(status){
printf("error!");
return -1;
}
status = pthread_join(tid2,NULL);
if(status){
printf("error!");
return -1;
}
return 0;
}