https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4a232e66-6c0c-467a-8534-6fa4bef73c85/Untitled.png

public class Singleton
{
    private static Singleton _UniqueInstance;
    private static readonly object _SyncLock = new Object();
 
    private Singleton() { }
 
    public static Singleton getInstance()
    {
        lock (_SyncLock)
            return _UniqueInstance ?? (_UniqueInstance = new Singleton());
    }
}
 
sealed class EagerSingleton
{
    // CLR eagerly initializes static member when class is first used.
    // CLR guarantees thread safety for static initialization.
    private static readonly EagerSingleton _Instance = new EagerSingleton();
 
    private EagerSingleton() { }
 
    public static EagerSingleton GetInstance() => _Instance;
}

Issues

Rules of Thumb