public void ensureIdIsMax(int msgId) throws InterruptedException {
        for (int i = 0; i < lastMsgIds.length(); ++i) {
            int id = lastMsgIds.get(i);
            if (id < msgId - 1
                    && threadStatuses.get(i) == ParallelThreadStatus.RUNNING) {
                Object lock = threadLocks.get(i);
                logger.debug("{} before thread lock {}", msgId, i);
                synchronized (lock) {
                    while (lastMsgIds.get(i) < msgId - 1
                            && threadStatuses.get(i) == ParallelThreadStatus.RUNNING) {
                        logger.debug("wait thread lock {} cause {} < {}",
                                lastMsgIds.get(i), msgId, i);
                        lock.wait();
                    }
                }
                logger.debug("{} after thread lock {}", msgId, i);
            }
        }
    }