Note: this question isn\'t related to volatile, AtomicLong, or any perceived deficiency in the described use case.
https://www.securecoding.cert.org/confluence/display/java/VNA05-J.+Ensure+atomicity+when+reading+and+writing+64-bit+values
VNA05-J. Ensure atomicity when reading and writing 64-bit values
....
VNA05-EX1: This rule can be ignored for platforms that guarantee that 64-bit long and double values are read and written as atomic operations. Note, however, that such guarantees are not portable across different platforms.
The link above discusses this issue in the context of security and seems to suggest that on 64 bit platforms you can indeed assume long assignments to be atomic. 32 bit systems are becoming somewhat rare in server environments, so it is not a strange assumption to make. Do note that the exception is a bit vague on which platforms make this guarantee and doesn't explicitly state that 64 bit openjdk on 64 bit intel is fine for example.
In fact, you've already answered your own question.
There is no "non-atomic treatment" of double
and long
on 64-bit HotSpot JVM, because