AdvancedMultithreadingLab.MiscBenchmarks.TestContendedEnter C# (CSharp) Method

TestContendedEnter() static private method

static private TestContendedEnter ( ) : void
return void
        static void TestContendedEnter()
        {
            const int n = 100000000;

            Stopwatch stopwatch = Stopwatch.StartNew();
            int j = 0;
            for (int i = 0; i < n; i++)
            {
                lock ( sync )
                {
                    j++;
                }

            }
            stopwatch.Stop();

            WriteTime("Contented Monitor", n, stopwatch.ElapsedTicks);
        }