std::thread main;
if (/*check code here*/)
{
main = std::thread(thread_hunt);
}
main.join();
This code will cause an error while main thread join if it is not initialized in the if-statement.
bool i=false;
std::thread main;
if (/*check code here*/)
{
main = std::thread(thread_hunt);
j=true;
}
if (j)
{
main.join();
}
The code works well,but is there a easier way I can achieve this goal?
Aucun commentaire:
Enregistrer un commentaire