|
Boost Users : |
Subject: Re: [Boost-users] Thread object pointers.
From: Eric J. Holtman (eric_at_[hidden])
Date: 2010-08-03 20:01:27
On 8/3/2010 4:10 PM, Albert Schueller wrote:
>
> int main(int argc, char* argv[])
> {
> int i;
> int num_thrds = 3;
> boost::thread *thrd[4];
>
> for(i=0;i<num_thrds;i++) {
> thrd[i] = new boost::thread(count(i+1));
> thrd[i]->join();
>
^^^^ that's your problem.
join won't return until the thread finishes
you need 3 loops.
first loop, call new, just like you were.
then
for i=0;i<num_thrds;i++) {
thrd[i]->join ();
}
then, run your delete loop.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net