samedi 23 mai 2015

Block main thread till worker thread terminates

I am new to c++ and I need to solve following problem

void thread_fun() {                                          
    //body
    //signal_main_thread to unblock
}

int main() {
     std::thread t(thread_fun);
     block on worker thread and waiting
     //body
     return 0;
}

I am sure I need to lock/semaphore/mutex but not sure how? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire