public void testSingletonOneForThread() { SingletonOneForThread s1 = SingletonOneForThread.Instance(); SingletonOneForThread s2 = SingletonOneForThread.Instance(); Assert.IsNotNull(s1); Assert.IsNotNull(s2); Assert.AreSame(s1, s2); }
public void testSingletonOneForThread_threads() { Thread t1, t2; SingletonOneForThread s1 = null, s2 = null; t1 = new Thread(() => { s1 = SingletonOneForThread.Instance(); }); t2 = new Thread(() => { s2 = SingletonOneForThread.Instance(); }); t1.Start(); t2.Start(); t2.Join(); t1.Join(); Assert.IsNotNull(s1); Assert.IsNotNull(s2); Assert.AreNotSame(s1, s2); }