idk what you're talking about, what I want to do is pretty obvious, however, if you don't understand it somehow compile and run the second program and ye shall see what I want.
I believe that last code has undefined behavior. In particular, the behavior is unpredictable in NUMA architectures. If should work fine if the bools are changed to std::atomic<bool>.
You can't post buggy code and expect someone to understand what your trying to do, if it was correct you might not have questions.
It's better to communicate what you want to do, then someone will be able to fix what you've posted.
The 2nd version of your code is wrong in principle. There are race conditions around the use of those global variables. You're lucky if you get the same results twice in a row.