Boost logo

Boost Users :

From: rgalek2002 (rfox_at_[hidden])
Date: 2002-06-10 13:05:07


I have an application which starts a number of threads, and I want
the application to wait for the threads to finish before exiting.
Standard stuff, I know, but never having used threads before I am
wondering what the stadard way is to accomplish this.

I have (psuedo code)

    for (each record in database) {
        thread thrd(func(), data);

I could imagine storing all my thread objects in a list, and then
calling join() on each one. For example something like

    list <thread> threads;
    for (each rec in db) {
       thread thrd(func(), data);
    list<thread>::iterator i;
    for (i=threads.begin(); i!=threads.end(); i++) {
       thread t = *i;

Does this seem reasonable? Is there a better/standard way? One thing
I don't like here is that each join will block, when what I would
like to do is something more like join_all();



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