Boost logo

Boost Users :

From: Alex MDC (alex.mdc_at_[hidden])
Date: 2008-05-15 09:58:12


I think your idea is pretty good, however instead of using sleep to
periodically check the shared counter, you might try using a condition
variable to notify the main thread that a worker thread has finished.

The example in the Boost.Thread documentation looks very close to what you
want.

Alex

On 15/05/2008, Axel <axel.azerty_at_[hidden]> wrote:
>
> Hello
>
> 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 ?
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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