1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
struct thread_param{
antnet *ser;
ant_pkt* ant;
};
typedef std::vector<struct thread_param> param_matrix;
....
static DWORD WINAPI ThreadLauncher(void *p)
{
struct thread_param *Obj = reinterpret_cast<struct thread_param*>(p);
return s->forward_ant(Obj->ant);
}
....
int main()
{
for(int j=0; j<iRandom;j++)
{
if(a<ant_max)
{
ant_pkt *Myant = new ant_pkt(src0,(G.dest_G)->GetNode(), s->cur_t , a);
struct thread_param p;
p.ser = s;
p.ant = Myant;
tempss.push_back(p);
hThreadArray[a] = CreateThread(NULL, 0,&ThreadLauncher, &p,0,&dwThreadIdArray[a]);
if ( hThreadArray[a] == NULL )
{
}
a++;
}
}
....
} |
Partager