Example #1
0
        public void ThreadSafetyRandomTest()
        {
            const int CONCURRENCY = 2;
            var       workers     = new TestWorker[CONCURRENCY];
            var       threads     = new Thread[CONCURRENCY];

            for (var i = 0; i < CONCURRENCY; i++)
            {
                workers[i] = new TestWorker();
                threads[i] = new Thread(workers[i].Random);
                threads[i].Start();
            }

            for (var i = 0; i < CONCURRENCY; i++)
            {
                threads[i].Join();
            }

            for (var i = 0; i < CONCURRENCY; i++)
            {
                Assert.IsNull(workers[i].Exception);
            }
        }
Example #2
0
        public void ThreadSafetyRandomTest()
        {
            const int CONCURRENCY = 2;
              var workers = new TestWorker[CONCURRENCY];
              var threads = new Thread[CONCURRENCY];

              for (var i = 0; i < CONCURRENCY; i++)
              {
            workers[i] = new TestWorker();
            threads[i] = new Thread(workers[i].Random);
            threads[i].Start();
              }

              for (var i = 0; i < CONCURRENCY; i++)
              {
            threads[i].Join();
              }

              for (var i = 0; i < CONCURRENCY; i++)
              {
            Assert.IsNull(workers[i].Exception);
              }
        }