public void consumeAll(long timeout,TimeUnit unit) throws TimeoutException {
  final long stopTime=System.currentTimeMillis() + unit.toMillis(timeout);
  while (System.currentTimeMillis() < stopTime) {
    Event nextEvent=queue.poll();
    if (nextEvent != null) {
      Testing.print("Found event: " + nextEvent);
      consumedEvents.accept(nextEvent);
    }
  }
}

public void consumeAll ( long timeout , TimeUnit unit ) throws TimeoutException { final long stopTime = System . currentTimeMillis ( ) + unit . toMillis ( timeout ) ; while ( System . currentTimeMillis ( ) < stopTime ) { Event nextEvent = queue . poll ( ) ; if ( nextEvent != null ) { Testing . print ( "Found event: " + nextEvent ) ; consumedEvents . accept ( nextEvent ) ; } } }
blocks for the specified amount of time , consuming ( and discarding ) all events .
