public boolean remove ( C consumer ) { if ( consumer != null ) { // Iterate through the map to find the runner that owns this consumer ... ConsumerRunner match = null ; for ( ConsumerRunner runner : consumers ) { if ( runner . getConsumer ( ) . equals ( consumer ) ) { match = runner ; break ; } } // Try to remove the matching runner (if we found one) from our list ... if ( match != null ) { // Tell the thread to stop and wait for it, after which it will have been removed from our map ... match . close ( ) ; return true ; } } // We either didn't find it, or we found it but something else remove it while we searched ... return false ; }
Remove the supplied consumer and block until it stops running and is closed and removed from this buffer . The consumer is removed at the earliest conevenient point and will stop seeing entries as soon as it is removed .