AdvancedMultithreadingLab.MiscBenchmarks.TestInterlocked C# (CSharp) Метод

TestInterlocked() приватный статический Метод

private static TestInterlocked ( string name ) : void
name string
Результат void
        private static void TestInterlocked(string name)
        {
            const int n = 100000000;

             Stopwatch stopwatch = Stopwatch.StartNew();
            for (int i = 0; i < n; i++)
            {
                Interlocked.CompareExchange( ref volatileField, volatileField + 1, volatileField );
            }
            stopwatch.Stop();

            WriteTime(name, n, stopwatch.ElapsedTicks);
        }