//
        // Starts the test.
        //

        internal static Action Run()
        {
            Random r = new Random(Environment.TickCount);

            for (int i = 0; i < QUEUES; i++)
            {
                switch (r.Next(3))
                {
                case 0:
                    queues[i] = new StUnboundedBlockingQueue <int>(false);
                    break;

                case 1:
                    queues[i] = new StBoundedBlockingQueue <int>(32 * 1024, false);
                    break;

                default:
                    queues[i] = new StArrayBlockingQueue <int>(32 * 1024, false);
                    break;
                }
            }
            for (int i = 0; i < CONSUMERS; i++)
            {
                new Consumer().Start(i, "c #" + i);
            }
            for (int i = 0; i < PRODUCERS; i++)
            {
                new Producer().Start(i, "p #" + i);
            }
            Action stop = () => {
                shutdown.Set();
                done.WaitOne();
                long ps = 0, cs = 0;
                for (int i = 0; i < PRODUCERS; i++)
                {
                    ps += productions[i];
                }
                for (int i = 0; i < CONSUMERS; i++)
                {
                    cs += consumptions[i];
                }

                VConsole.WriteLine("+++ Total: prods = {0}, cons = {1}", ps, cs);
            };

            return(stop);
        }
        //
        // Starts the test.
        //

        internal static Action Run() {
            Random r = new Random(Environment.TickCount);
            for (int i = 0; i < QUEUES; i++) {
                switch (r.Next(3)) {
                    case 0:
                        queues[i] = new StUnboundedBlockingQueue<int>(false);
                        break;
                    case 1:
                        queues[i] = new StBoundedBlockingQueue<int>(32 * 1024, false);
                        break;
                    default:
                        queues[i] = new StArrayBlockingQueue<int>(32 * 1024, false);
                        break;
                }
            }
            for (int i = 0; i < CONSUMERS; i++) {
                new Consumer().Start(i, "c #" + i);
            }
            for (int i = 0; i < PRODUCERS; i++) {
                new Producer().Start(i, "p #" + i);
            }
            Action stop = () => {
                shutdown.Set();
                done.WaitOne();
                long ps = 0, cs = 0;
                for (int i = 0; i < PRODUCERS; i++) {
                    ps += productions[i];
                }
                for (int i = 0; i < CONSUMERS; i++) {
                    cs += consumptions[i];
                }

                VConsole.WriteLine("+++ Total: prods = {0}, cons = {1}", ps, cs);
            };
            return stop;
        }