"Implementing a ... and Writers" uses broken idiom


TSS feedback: "Implementing a ... and Writers" uses broken idiom

  1. In the article "Implementing a Data Cache using Readers and Writers" the author uses, in the paragraph "Creating a lock" the "Double-Checked Locking" idiom to avoid a synchronized method. As I understand it this does not work. More information is available from http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html which has a detailed explanation of why this is. I wonder if anyone has any comments about this.

  2. You're right

    We need to hold Billy gravely responsible for this terrible mistake :)

    There are two errors there:
      - Static singletons with lazy instantiation can safely be implemented without double checked locking by using a separate class with static initializer.
      - lazy instantiation is really unnecessary for that particular case.

    Billy, what's up man ?