For years and years, I\'ve tried to understand the part of Java specification that deals with memory model and concurrency. I have to admit that I\'ve failed miserably. Yes\
volatile
variables can be cached thread-locally, so different threads may see different values at the same time; volatile
prevents this (source)long
and double
, though 64bit JVMs probably implement them as atomic operations