Versions Compared

Key

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

...

Immutable members can be safely published by declaring them volatile as described in CON00-J. Declare shared variables as volatile to ensure visibility and prevent reordering of accessesKnow when to use volatile.

Code Block
bgColor#CCCCFF
class Foo {
  private volatile Helper helper;

  public Helper getHelper() {
    return helper;
  }

  public void initialize(int num) {
    helper = new Helper(num);
  }
}

...