예제 #1
0
        public void ThreadX()
        {
            long res = 0;

            for (int i = 0; i < 10000; i++)
            {
                _locker.Enter();
                Interlocked.Increment(ref concurrent);
                for (int z = 0; z < 1000; z++)
                {
                    res += res;
                }
                if (concurrent > 1)
                {
                    Console.WriteLine("{0} concurrency issues!", _locker.GetType().Name);
                }

                Interlocked.Decrement(ref concurrent);
                _locker.Exit();
            }
        }