Ben J. Christensen

Software Development and Other Random Stuff

Double Check Locking

Recently re-visited the double-check-locking pattern (or anti-pattern).

It doesn’t work in JDK 1.4 and earlier … however, in JDK 5, it’s updated memory model allows it to be used safely.

Wikipedia – Double Check Locking

Sun Blog on JDK 5 and Double Check Locking

Another possible solution that has the benefit of enforcing compilation ONLY with JDK 1.5 and later is a use of something called AtomicReference.

I haven’t played with them yet, but some information can be found at:

Introduction to Non-Blocking Algorithms


Filed under: Code

Leave a Reply

Twitter Updates

  • I *really* wish iBooks and Kindle would let me copy/paste text so I can quote a sentence or paragraph! Ridiculous that I can't. 23 hours ago
  • Great weekend (and ‘food tourism’) in Los Angeles. "Sooo fun!" as described by a certain short person when asked on the drive home. 1 day ago
  • Small world! Just ran into a colleague from work - a 7hr drive from the office! 1 day ago
  • We made it to LA! Feels like returning home :-) 3 days ago
  • Peter Pan Baby http://twitpic.com/2kg6n4 5 days ago
View Ben Christensen's profile on LinkedIn