Singletons, volatile and memory barriers

Brad Abrams on volatile and MemoryBarrier(). Someone sent this to the team and I couldn’t stop myself from reading it.

If you use the double check locking pattern, then most probably you are already aware of the pitfalls in it. Using volatile introduces a performance hit and memory barriers can help you to avoid this. My personal preference is to avoid lazy instantiation if possible.