private void submit(Object input) {
        Job job = new Job(input, nextMessageId++);
        while (!window.reserveCell() && !interrupted) {
            interrupted |= Thread.interrupted();
            int inserted = 0;
            for (int i = 0; i < workers.length; ++i) {
                inserted += getOutAndInsert(i);
            }
            if (inserted == 0) {
//                Thread.yield();
            }
        }
        while (job != null && !interrupted) {
            interrupted |= Thread.interrupted();
            int i = 0;
            for (; i < workers.length; ++i) {
                if (workers[i].in == null) {
                    logger.debug("message {} is sent to worker {}.", job, i);
                    workers[i].in = job;
                    job = null;
                    break;
                }
                getOutAndInsert(i);
            }
            for (; i < workers.length; ++i) {
                getOutAndInsert(i);
            }
        }
    }