Beispiel #1
0
        public override void UpdateArray(ref int counter, int[] m1)
        {
            counter++;
            if (counter < ItersToUpdate)
            {
                return;
            }

            counter = 0;

            var spinWait = new SpinWait();

            while (locked)
            {
                Thread.MemoryBarrier();
                spinWait.SpinOnce();
            }

            locked = true;

            Console.WriteLine(Thread.CurrentThread.Name + " обновляет массив...");
            Array.Copy(m1, M1, m1.Length);

            locked = false;

            SearchEvent.Set();
        }
Beispiel #2
0
        public override void UpdateArray(ref int counter, int[] m1)
        {
            counter++;
            if (counter < ItersToUpdate)
            {
                return;
            }

            counter = 0;

            lock (locker)
            {
                Console.WriteLine(Thread.CurrentThread.Name + " обновляет массив...");
                Array.Copy(m1, M1, m1.Length);
            }

            SearchEvent.Set();
        }