Example #1
0
        static void CheckElementsRange()
        {
            MyHashSet <int> set = new MyHashSet <int>();

            int numOfParallelCheckers = 50;
            int numOfRepetitions      = 1000;
            int checkSize             = 10;
            int currentStart          = 0;

            CheckElementsRange[] checkers = new CheckElementsRange[numOfParallelCheckers];
            Thread[]             threads  = new Thread[checkers.Length];
            for (int i = 0; i < checkers.Length; i++)
            {
                checkers[i] = new CheckElementsRange(set, currentStart, currentStart + checkSize, numOfRepetitions);
                threads[i]  = new Thread(checkers[i].Run);
            }

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Start();
            }

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
            }

            Console.WriteLine("If you do not see any error messages, it means that the checkers have finished ok");
        }
Example #2
0
 /// <summary>
 /// Inclusive min, exclusive max
 /// </summary>
 /// <param name="set"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="repetitions"></param>
 public CheckElementsRange(MyHashSet <int> set, int min, int max, int repetitions)
 {
     this.set         = set;
     this.min         = min;
     this.max         = max;
     this.repetitions = repetitions;
 }