
I think boost::barrier is what you look for. Supposed an algorithm function looks like this void MyAlgorithm( boost::barrier& i_FistAlgorithmDone ) { // run algo //... i_FistAlgorithmDone.wait(); } Then the main thread would look like this: // 2 waits, one from the main thread, the other from the first algo boost::barrier FistAlgorithmDone( 2 ); boost::thread_group tg; // ... // pass in FistAlgorithmDone to your algorithm functions Tg.create_thread( std::tr1::bind( &MyAlgorithm, std::tr1::ref( FistAlgorithmDone ) ); // crate next thread ... // wait for the first algo to finish FistAlgorithmDone.wait(); // wait for the remaining algos to finish boost::thread* first = tg.join_one(); I can't verify if this compiles atm. Sry for that. I hope this is what you look for. Best Jochen -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of vicente.botet Sent: Wednesday, April 30, 2008 1:29 PM To: boost@lists.boost.org Subject: [boost] [thread]joining the first thread finishing from a group ofthreads Hello, I have several implementations of the same function with different algorithms. I want to launch these in parallel and join the one finishing the first, and stop the others. I have started and in my solution I need to wrap the function in order to make the needed synchronization, which seam not quite satisfactory. Is there an easy way to join the first thread that finish from a thread group and getting it? boost::thread_group tg; // ... boost::thread* first = tg.join_one(); Do you find useful this feature? Regards _____________________ Vicente Juan Botet Escriba _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost