If I have only two threads, and I want one of them to wait for the other to reach a certain point, is it safe to do the following:
bool wait = true;
//Thread 1:
while(wait) ;
wait = true; //re-arm the signal
//Thread 2:
/* Preform here the code that needs to complete before Thread 1 continues */
wait = false;
Basically, if one thread only writes to it and the other only reads, can there be a problem? I assume a read or a write of a single bool
is atomic, and even if not, I don't see how it can make a difference here.