tag:blogger.com,1999:blog-6109902428394591235.post6301318661076485603..comments2023-10-12T16:30:29.402+05:30Comments on Technology Blog - Vikas Goyal: * Singleton Creational PatternVikas Goyalhttp://www.blogger.com/profile/10253625012938454368noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6109902428394591235.post-7110568290366747522009-02-11T08:51:00.000+05:302009-02-11T08:51:00.000+05:30I don't believe that the Singleton class (as prese...I don't believe that the Singleton class (as presented) is thread safe. To ensure that only one instance is going to be created, regardless of threads, change the Instance declaration to look like this:<BR/><BR/><B>private static readonly Singleton Instance;</B><BR/><BR/>The above is the .NET Framework approach to a thread-safe singleton. With a static readonly member, the internal framework guarantees that only one instance will ever be created.<BR/><BR/>If you want a traditional thread-safe approach, you'll need to introduce double check locking. Check out this article from my colleague, Mark Townsend:<BR/><BR/>http://msdn.microsoft.com/en-us/library/ms954629.aspxAnonymousnoreply@blogger.com