There are different solutions possible, the most obvious is to use a global variable (boolean, mutex or handle) to signal the exit.
pseudo-code:
bool stopThread = false;
void threadOne()
{
if( timeToLeave ) {
stopThread = true;
}
}
void threadTwo()
{
while( !stopThread ) {
}
}
If you dont like it read the
documenation and "maybe" you can do stuff like that
std::thread *myThread = new std::thread(...);delete myThread;
I wish you good luck...