Since no one has answered your actual question and instead are showing you how to do it in a way that always works:
Thread 1 loads value of 0
Thread 2 loads value of 0
Thread 1 increments an stores 1
Thread 2 increments its local register copy of value and stores 1.
As you can see the end result is a value equal to 1 and not 2.  It will not always be 2 at the end.