Boost logo

Boost Users :

Subject: Re: [Boost-users] Fwd: boost::thread and corresponding stack array
From: Igor R (boost.lists_at_[hidden])
Date: 2010-06-05 13:22:07


> Therefore, if you want an array of threads, you need to allocate each thread object
> individually on the heap, like:
>
> boost::thread* thr[SIZE];
> for (int i = 0; i < SIZE; ++i) thr[i] = new boost::thread(functor);
>
> Then of course, you need to iterate through the array later and call delete
> on each thread object.

Consider using thread_group:

http://www.boost.org/doc/libs/1_43_0/doc/html/thread/thread_management.html#thread.thread_management.threadgroup


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