Henry Wong wrote: . . .
Run this program, and you will see an eleven appear from time to time.
Henry
I did, only I had the volatile field initialised to 0, so I saw lots of 1s and lots of 0s.
Is that because the field is marked volatile? Does the value of
x get written back to RAM after the
x++ is executed? Then the value read from the print call is taken from RAM?
Would that not happen were the field not marked volatile? Would that be because the new value is held in cache or register to be reassigned to
x immediately?