forked from kamranahmedse/design-patterns-for-humans
-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Description
The provided example for Singleton design pattern is not thread safe. This is the most basic implementation of the Singleton pattern. Please add the thread safe, lazy implementation.
public sealed class Singleton
{
private static readonly Lazy<Singleton> lazy =
new Lazy<Singleton>(() => new Singleton());
public static Singleton Instance { get { return lazy.Value; } }
private Singleton()
{
}
}
Below article from Jon Skeet would be helpful
http://csharpindepth.com/Articles/General/Singleton.aspx
Enissay and alexmartinezm
Metadata
Metadata
Assignees
Labels
No labels