-
-
Save cgatian/6193655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Singleton | |
{ | |
private static readonly Lazy<Singleton> _lazy = new Lazy<Singleton>( | |
() => new Singleton(), isThreadSafe: true); | |
public static Singleton Instance | |
{ | |
get | |
{ | |
return Singleton._lazy.Value; | |
} | |
} | |
private Singleton() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified by removing LazyThreadSafetyMode.ExecutionAndPublication in favor of a specified a named parameter (isThreadSafe) for human readability.