
4 Aug
2010
4 Aug
'10
12:04 a.m.
Hi Albert,
On Tue, Aug 3, 2010 at 3:10 PM, Albert Schueller
When I run LISTING 1 it appears that the threads are acting independently as I would hope. When I run LISTING 2, it seems that the threads are not independent, but rather thrd1 does its job, followed by thrd2, followed by thrd3.
Am I not locking properly?
Could it be that:
for(i=0;i
join(); }
Should be: for(i=0; i < num_thrds; i++) thrd[i] = new boost::thread(count(i+1)); for(i=0; i < num_thrds; i++) thrd[i]->join(); Calling join prior to creating the next thread would cause the sequential execution you were seeing. HTH, Nate