Exemplo n.º 1
0
        public void SimpleAtomicityTest3b()
        {
            racyvariable = 0;

            Thread t = new Thread((Object irrelevant) =>
            {
                ChessAPI.RunWithoutPreemptions(() =>
                {
                    racyvariable++;
                });
            });

            t.Start();

            try
            {
                ChessAPI.RunWithoutPreemptions(() => ((Object)(null)).GetHashCode());
            }
            catch (NullReferenceException)
            {
            }

            racyvariable++;

            t.Join();

            Assert.AreEqual(2, racyvariable);
        }