I donβt think anyone really answered the question, so Iβll try.
Volatile and first if (instance == null) are not "necessary". Blocking will make this code thread safe.
So the question is: why are you adding the first if (instance == null) ?
The reason, apparently, is to avoid unnecessarily executing a blocked section of code. While you are executing code inside the lock, any other thread that also tries to execute this code is blocked, which will slow down your program if you try to access the singleton often from many threads. Depending on the language / platform, there may also be overhead from the castle itself that you want to avoid.
So, the first zero check is added as a very quick way to see if you need a lock. If you do not need to create a singleton, you can completely lock the lock.
But you cannot check if the link is null without blocking it in any way, because due to caching of the processor, another thread may change it, and you will read the "obsolete" value, which will lead you to unnecessarily enter the lock, But You are trying to avoid blocking!
So you are doing singleton volatile to make sure you read the last value, without having to use a lock.
You still need an internal lock, because volatile protects you with only one access to the variable β you cannot safely test and set it without using a lock.
Now, is this really helpful?
Well, I would say "in most cases, no."
If Singleton.Instance can cause inefficiencies due to locks, why do you call it so often that this will be a serious problem? The whole point of singleton is that there is only one, so your code can read and cache a singleton link once.
The only time I can think about where this caching would be impossible is when you have a large number of threads (for example, a server using a new thread to process each request can create millions of very short threads, each of which should have would call Singleton.Instance once).
Thus, I suspect that a double-checked lock is a mechanism that has a real place in very specific cases with critical criticism, and then everyone climbed to "this is the right way to do this," winning, without actually thinking about what he was doing and whether it will really be necessary if they use it for.