Race condition: Min and Max range of an integer
I claim the minimum value possible is 2. The key to this is the non-atomicity of num++, i.e., it is a read and a write, which may have other operations in between. Call the threads T1..T5: T1 reads 0, T2 reads 0; T1 writes 1, and then reads and writes 3 times. Then T2 writes … Read more