Code example for TimeoutException

0
    } 
 
    public void awaitOneCallback(long timeout, TimeUnit unit) throws InterruptedException,
            TimeoutException { 
        if (mQueue.poll(timeout, unit) == null) {
            throw new TimeoutException();
        } 
    } 
 
    public void assertNoMoreCallbacks() { 
        if (mQueue.peek() != null) {
            throw new IllegalStateException("there was an unexpected callback on the queue");
        } 
    } 
}