今天有点思维短路,看完一段有问题的代码,感觉还很对。代码模型如下:
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
typedef struct POINT{
int type ;
int x;
int y;
}POINT;
POINT * p;
void * p_han(void * arg)
{
int idx = *(int *)arg ;
printf("p_han ------------------ type:%d(x= %d ,y = %d ) \n",p[idx].type,p[idx].x,p[idx].y);
}
void * p_han1(void * arg)
{
int idx = *(int *)arg ;
printf("p_han1 ------------------ type:%d(x= %d ,y = %d ) \n",p[idx].type,p[idx].x,p[idx].y);
}
int hande(int idx)
{
pthread_t pid ;
if(p[idx].type == 1 )
{
pthread_create( &pid,NULL,p_han,(void *)&idx);
}
else if( p[idx].type == 0)
{
pthread_create( &pid,NULL,p_ha