I saw in a mprss book this recommendation of singleton (partial code attached):
public static Singleton GetSingleton()
{
if (s_value != null)
retur
While the assignment is atomic, it is also required that the memory is "synchronized" across the different cores/CPUs (full fence), or another core concurrently reading the value might get an outdated value (outside of the synchronization block). The Interlocked
class does this for all its operations.
http://www.albahari.com/threading/part4.aspx
Edit: Wikipedia has some useful information about the issues with the double-locking pattern and where/when to use memory barriers for it to work.