static void SampleMultiThreadSingleton() { LogFileSingleton _sampleLog = LogFileSingleton.ThreadSafeGetInstance(); Thread threadA = new Thread(() => _sampleLog.LogContent("Log Content A")); Thread threadB = new Thread(() => _sampleLog.LogContent("Log Content B")); threadA.Start(); threadB.Start(); }
static void SampleSingleton() { LogFileSingleton _sampleLog = LogFileSingleton.LazyGetInstance(); _sampleLog.LogContent("Sample Log"); }