Boost logo

Boost Users :

Subject: [Boost-users] Beginning with thread
From: Kraus Philipp (philipp.kraus_at_[hidden])
Date: 2010-08-13 07:46:35


I would like to use Boost threads, but I don't work with them. I know
only Java Threads.

The problem, in which should use threads:
I have some stochastic and numerical optimization, which all can
calculate independent (no mutex, synchronizsation or something else).

I've found boost::thread and boost::bind for creating threads (call a
method of an object).

In Java I would write this code structure:

myThread first = new myThread();

Thread th = new Thread(first);


I would like to have an object of calculation, which receives only
after creating different parameters and then calculates the data on
more than one thread.
After completion of the calculation, I can let me deliver the data
back from any object, like:

std::vector<myWorker> x;
for(int i=0; i < numThreads; ++i) {
      x.push_back( myWorker() );

createThreadGroup (x);
wait until ThreadGroup is finish

for(int i=0; i < numThreads; ++i)

How can do this with Boost Thread? Is this the correct way or can I do
this more efficient?



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at