I am stopping two threads like so for each thread:
if(myState == NORMAL)
{
InterlockedIncrement(&myState);
//myState = STOPPED;
}
while(myState == STOPPED);
now this is for two threads, now when a third thread find thats both have stopped it starts them again like so:
if(Gary->myState == STOPPED && Zoey->myState == STOPPED )
{
Gary->myState = NORMAL;
Zoey->myState = NORMAL;
}
The problem is that the while loop is stupid. But I dont know another way to do this. I could try sleep but too high would waste time, and too low would be the same as a while();. So what is the best way to make a thread "wait", but not doing any instructions so that the other thread can go faster.