typedef struct {
int param1;
int param2;
int param3;
int param4;
}agent_threadParma;
int canReceive(void *pParams)
{
agent_threadParma *param;
param = (agent_threadParma*)pParams;
fd = param ->param1; //此数传递有时正确有时不正确
while(1)
{
......
}
}
int cansio_open()
{
agent_threadParma threadParams; //自定义结构
pthread_t canthread;
int fd;
......
fd = open( candev, O_RDWR|O_NONBLOCK );
if (-1 == fd)
{
perror("Can't can Port");
return -1;
}
threadParams.param1 = fd;
pthread_create(&canthread,NULL,(void *)canReceive,(void*)&threadParams);
.......
}
我使用 pthread_create来产生线程,但是 threadParams.param1 参数传递传递有时正确有时不正确,我不知到为什么会
这样,谁能给我分析一下? |