my understanding of atomicity is either not done or finished.
A variable with atomic operations atomic < int > gCounter;
. There are two threads that perform write operations on gCounter
. If these two threads happen to perform write operations at the same time, won"t this result in data-race?
I know it will not cause data-race, but I looked up the information on the Internet and found nothing that can refute my above point of view. My personal guess is that the processor will add locks when performing atomic operations, but of course this is just a personal guess.
I hope someone will answer the question.