Boost logo

Boost Users :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2008-05-15 09:42:17


Axel <axel.azerty_at_[hidden]> writes:

> I m writting a program which create threads following commands received
> on a socket connection.
> When exiting, I'd like to wait that all dynamically created threads have
> ended their jobs.
> I thought about using a shared variable (with mutual exclusion) that
> threads would increment at start and decrement at end.
> And then the program would stop, loop on sleep() while this shared
> variable is still > 0.
>
> Is there a better way to wait for the end of threads ?

Call t.join() for each thread t. Alternatively put them all in a thread_group
and call join_all().

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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