...
This compliant solution declares the variables as volatile
. Writes and reads of volatile long and double values are always atomic.
Code Block | ||
---|---|---|
| ||
class Test { static long i = 0; static void one() { i++; } static void two() { System.out.println("i =" + i); } } |
...