PhreadItemsVecPos_t* ItItemsVec_ = new PhreadItemsVecPos_t;//多个参数要用struct传递、每个地址必须new出来
PhreadItemsVecPos_t& ItItemsVec = *ItItemsVec_;
if(ItemsVecPos+VecDivCount<(int)ItemsVec.size())
{
ItItemsVec.ItemsB = ItemsVecPos;
ItItemsVec.ItemsE = ItemsVecPos + VecDivCount;
}
else
{
ItItemsVec.ItemsB = ItemsVecPos;
ItItemsVec.ItemsE = (int)ItemsVec.size();
}
// int *p =(int *) &(*it);
pthread_create(&CalcThread[i],NULL,Calc_item_,&ItItemsVec);
}
for(int i=0; i< ThreadCount; ++i)
{
pthread_join(CalcThread[i],NULL);
}
Pthread_create与pthread_join要配对;
关键点在怎样把数据分段
阅读(1706) | 评论(0) | 转发(0) |