Technically yes, but no on many platforms. First, suppose int is 32 bits (which is pretty common, but not nearly universal).
It is possible that two words (16 bits) of 32 bits of int will be read or written separately. On some systems, they will be read separately if the int misaligned.
Imagine a system in which you can only execute 32-bit aligned 32-bit reads and writes (and 16-bit aligned 16-bit reads and writes) and int that cross such a boundary. The int is initially zero (i.e. 0x00000000 )
One thread writes 0xBAADF00D to int , the other reads it "at the same time".
The writing stream first writes 0xBAAD to the upper word int . Then the read stream reads all int (both high and low), getting 0xBAAD0000 - this is the state in which int never put into action!
Then, the recording stream writes the bottom word 0xF00D .
As already noted, on some platforms, all 32-bit reads / writes are atomic, so this is not a problem. However, there are other problems.
In most cases, the lock / unlock code contains instructions for the compiler to prevent lock reordering. Without this prevention of reordering, the compiler can freely reorder things, as long as it behaves "as is" in a single stream context, it would work that way. Therefore, if you read a and then b in the code, the compiler could read b before it reads a if it does not see that the in-thread capability for b should be changed at that interval.
Thus, it is possible that the code you are reading uses these locks to ensure that the variable is being read in the order specified in the code.
Other questions are covered in the comments below, but I donβt feel competent in solving them: cache problems and visibility.