All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.pmd.rules.pmd.DoubleCheckedLocking.html Maven / Gradle / Ivy

Go to download

PMD is a tool that looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions or duplicate code.

There is a newer version: 2.4
Show newest version
Partially created objects can be returned by the Double Checked Locking pattern when used in Java. An optimizing JRE may assign a reference to the baz variable before it creates the object the reference is intended to point to. More details. Example :
public class Foo {
  Object baz;
  Object bar() {
    if(baz == null) { //baz may be non-null yet not fully created
      synchronized(this){
        if(baz == null){
          baz = new Object();
        }
      }
    }
    return baz;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy