vendredi 20 avril 2018

How to loop using threads and exit when they are finished?

I need to loop the function using several threads and exit from the external function when all the threads are finished. How can I fix my code?

void ff()
{
    for (int i = 0; i < THREADS; ++i) {
        std::thread thr(f, i);
        //
    }

    // Wait until all the threads are finished
}

Aucun commentaire:

Enregistrer un commentaire