Beispiel #1
0
        public void ZadanieASingletonWithLockManyTasks()
        {
            Task[] tasks = new Task[100];
            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = new Task(() =>
                {
                    SingletonWithLock s = SingletonWithLock.GetSingleton();
                });
                tasks[i].Start();
            }

            tasks.AsParallel().ForAll(task => task.Wait());
            Assert.AreEqual(SingletonWithLock.constructorCount, 1, "Ilość Singletonów różna od 1!");
        }
Beispiel #2
0
        public void ZadanieASingletonWithLockOneTask()
        {
            SingletonWithLock s = SingletonWithLock.GetSingleton();

            Assert.AreEqual(SingletonWithLock.constructorCount, 1, "Ilość Singletonów różna od 1!");
        }