static void Main(string[] args) { SingletonClass singletonOne = SingletonClass.Instance; singletonOne.ShowMessage(); SingletonClass singletonTwo = SingletonClass.Instance; DoWork(singletonTwo); // потокобезопасная реализация (new Thread(() => { ThreadSafeSingleton instanceOne = ThreadSafeSingleton.Instance; } )).Start(); ThreadSafeSingleton instanceTwo = ThreadSafeSingleton.Instance; Console.ReadLine(); }
private static void DoWork(SingletonClass singleton) { singleton.ShowMessage(); }