question: 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 ) ; }
target:  Iterate through all entries and remove the obsolete ones.