"volatile
" does not replace Interlocked.Increment
! It just makes sure that the variable is not cached, but used directly.
Incrementing a variable requires actually three operations:
- read
- increment
- write
Interlocked.Increment
performs all three parts as a single atomic operation.