来源:statckoverflow

Not sure if I understand your question correctly, but the JLS 8.3.1.4. volatile Fields states:

and, perhaps more importantly, JLS 17.7 Non-atomic Treatment of double and long :

That is, the "entire" variable is protected by the volatile modifier, not just the two parts. This tempts me to claim that it's even more important to use volatile for longs than it is for ints since not even a read is atomic for non-volatile longs/doubles.

12-20 16:45