Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This compliant solution declares the variables as volatile. Writes and reads of volatile long and double values are always atomic.

Code Block
bgColor#FFcccc#ccccff
class Test {
  static long i = 0;
  static void one() { i++; }
  static void two() {
    System.out.println("i =" + i);
  }
}

...