I just tested something like this:
boost::thread workerThread1(boost::bind(&Class::Function, this, ...);
boost::thread workerThread2(boost::bind(&Cla
Why don't you use boost::thread_group? You can create/add/remove threads and join them all (boost::thread_group::join_all()
).
boost::thread_group tgroup;
for(...)
{
tgroup.create_thread(boost::bind(&Class::Function, this, ...)) ;
}
tgroup.join_all();
But be careful about the number threads you are creating, too many threads may lead to OutOfMemory
.