title: Why Double checked locking is 25% faster in Joshua Bloch Effective Java Example
body: <p>Below is a snippet from Effective Java 2nd Edition. The author claims that the following piece of code is 25% faster than a code in which you do not use the <code>result</code> variable.
  According to the book &quot;What this variable does is to ensure that field is read only once in the common case where it’s already initialized.&quot; .
  I am  not able to understand why this code would be faster after the value is initialized compared to if we do not use the local variable result. In either case you will have only one volatile read after initialization whether you use the local variable result or not.</p>
  <pre><code>// Double-check idiom for lazy initialization of instance fields 
  private volatile FieldType field;
  
  FieldType getField() {
      FieldType result = field;
      if (result == null) {  // First check (no locking)
          synchronized(this) {
              result = field;
              if (result == null)  // Second check (with locking)
                  field = result = computeFieldValue();
          }
      }
      return result;
  }
  </code></pre>