public Element getElement(long timeout, TimeUnit unit) throws InterruptedException {
        return elements.poll(timeout, unit);
    }
Retrieves and removes the first received element that was stored in the queue, waiting
if necessary up to the specified wait time if no elements are present on this queue.

@param timeout how long to wait before giving up, in units of {@code unit}.
@param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter.
@return the head of this queue, or {@code null} if the specified waiting time elapses
        before an element is present.
@throws InterruptedException if interrupted while waiting.
xmppserver/src/main/java/org/jivesoftware/openfire/server/OutgoingServerSocketReader.java