public void doEvents ( ) { while ( ! isInterrupted ( ) ) { Iterator < Map . Entry < Timer , Runnable > > it = timerMap . entrySet ( ) . iterator ( ) ; if ( it . hasNext ( ) ) { long timeout = it . next ( ) . getKey ( ) . uptime - System . currentTimeMillis ( ) ; doEvents ( timeout > 0 ? timeout : 0 ) ; } else { doEvents ( - 1 ) ; } } }
Consume events until interrupted