What could happen if two threads access the same bool variable at the same time?
问题 I have a cross platform c++ program where I'm using the boost libraries to create an asynchronous timer. I have a global variable: bool receivedInput = false; One thread waits for and processes input string argStr; while (1) { getline(cin, argStr); processArguments(argStr); receivedInput = true; } The other thread runs a timer where a callback gets called every 10 seconds. In that callback, I check to see if I've received a message if (receivedInput) { //set up timer to fire again in 10