void build(int numberThreads, int numberQueues, int queueCapacity)
            throws InterruptedException
    {
        logger.info("started threads f{}; queues {}; queue capacity {}",
                numberThreads, numberQueues, queueCapacity);
        final SyncBar bar = new SyncBar(numberQueues, numberThreads, queueCapacity);
        ExecutorService pool = Executors.newCachedThreadPool();
        CountDownLatch latch = new CountDownLatch(numberQueues);
        List<IdHandler> handlers = new ArrayList<IdHandler>();
        for (int i = 0; i < numberQueues; ++i) {
            IdHandler handler = new IdHandler(latch, N_MESSAGES, i, numberQueues);
            handlers.add(handler);
            pool.submit(new OrderMultiplexer(handler, i, bar));
        }
        WaitPutQueue<Integer> in = new WaitPutQueueImpl<Integer>(
                new ArrayDeque<Integer>(IN_QUEUE_CAPACITY));
        for (int thrId = 0; thrId < numberThreads; ++thrId) {
            pool.submit(new ParallelImpl(in, bar, thrId, numberQueues));
        }
        pool.submit(new InFiller(in, N_MESSAGES));
        latch.await();
        logger.info("All messages arrived. Checking...");
        for (IdHandler handler : handlers) {
            Assert.assertEquals(0, handler.getNumProblems());
        }
        pool.shutdown();
    }