public boolean waitSize(int size, int seconds) {
        long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(seconds);
        while (true) {
            if (size() == size) {
                return true;
            }
            if (System.currentTimeMillis() > timeout) {
                return false;
            }
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                return false;
            }
        }
    }
@author <a href="mailto:havardpe@yahoo-inc.com">Haavard Pettersen</a>
messagebus/src/main/java/com/yahoo/messagebus/test/QueueAdapter.java