Ben J. Christensen

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Twitter Updates

View Ben Christensen's profile on LinkedIn
Follow

Get every new post delivered to your Inbox.