Is there any potencial problem when invoking the std::thread::detach() in the Lambda function to detach the newly created thread itself?
Here is the related code snippet:
void MainWindow::deployAction(void)
{
std::thread workThread([&]()
{
workThread.detach();
do_some_process_for_seconds();
return;
});
sleep_or_do_sth_for_minutes(); //long enough, the code in practice may use conditional_variable to know the child thread has finished its work.
}
Aucun commentaire:
Enregistrer un commentaire