private void monitorCallBacks ( ) { if ( futureList . size ( ) > 0 ) { final List < AsyncFutureCallback < ? > > removeList = new ArrayList <> ( futureList . size ( ) ) ; long now = currentTime ; for ( AsyncFutureCallback < ? > callback : futureList ) { if ( callback . isDone ( ) ) { callback . run ( ) ; removeList . add ( callback ) ; } else { if ( callback . checkTimeOut ( now ) ) { removeList . add ( callback ) ; } } } futureList . removeAll ( removeList ) ; } }
Monitors timeouts . If the callback timed - out trigger it and then remove callback from the list .