>
>This looks like the 'super-safe' C# implementation:public sealed class Singleton
>>{
>> private static volatile Singleton instance;
>> private static object syncRoot = new Object();
>>
>> private Singleton() {}
>>
>> public static Singleton Instance
>> {
>> get
>> {
>> if (instance == null)
>> {
>> lock (syncRoot)
>> {
>> if (instance == null)
>> instance = new Singleton();
>> }
>> }
>>
>> return instance;
>> }
>> }
>>}
(from http://msdn.microsoft.com/en-us/library/ff650316.aspx). Only problem is that VB doesn't have 'volatile' :-{ >
>This "volatile" keyword is a new one for me (been around awhile, but I guess I hadn't heard of it). The link you provided to MSDN states that if your member is declared using the volatile keyword, then you don't have to use a lock ... so, if that's the case, then I'm confused why you did ... guess I should probably read up on it more at some point.
I think it's mainly to prevent the compiler pulling a fast one in the way of optimisation:
http://msdn.microsoft.com/en-us/library/aa645755(v=vs.71).aspx