private void sweep(){
  final long oldestAllowed=System.currentTimeMillis() - exchangeLifetime;
  final long start=System.currentTimeMillis();
  for (  Map.Entry<?,Exchange> entry : incomingMessages.entrySet()) {
    Exchange exchange=entry.getValue();
    if (exchange.getTimestamp() < oldestAllowed) {
      LOGGER.log(Level.FINER,"Mark-And-Sweep removes {0}",entry.getKey());
      incomingMessages.remove(entry.getKey());
    }
  }
  LOGGER.log(Level.FINE,"Sweep run took {0}ms",System.currentTimeMillis() - start);
}

private void sweep ( ) { final long oldestAllowed = System . currentTimeMillis ( ) - exchangeLifetime ; final long start = System . currentTimeMillis ( ) ; for ( Map . Entry < ? , Exchange > entry : incomingMessages . entrySet ( ) ) { Exchange exchange = entry . getValue ( ) ; if ( exchange . getTimestamp ( ) < oldestAllowed ) { LOGGER . log ( Level . FINER , "Mark-And-Sweep removes {0}" , entry . getKey ( ) ) ; incomingMessages . remove ( entry . getKey ( ) ) ; } } LOGGER . log ( Level . FINE , "Sweep run took {0}ms" , System . currentTimeMillis ( ) - start ) ; }
iterate through all entries and remove the obsolete ones .
