semaphore.wait(1000);
semaphore.wait(4000);
    public void waitForMessagesToArrive(int messageCount) {        log.info("Waiting for message to arrive");        long start = System.currentTimeMillis();        while (System.currentTimeMillis() - start < 10000) {            try {                if (hasReceivedMessages(messageCount)) {                    break;                }                synchronized (semaphore) {                    semaphore.wait(1000);                }            }            catch (InterruptedException e) {                log.info("Caught: " + e);            }        }        long end = System.currentTimeMillis() - start;        log.info("End of wait for " + end + " millis");    }