public Future add ( long delay , Runnable run ) { final int curSlot = currentSlot ; final int ticks = delay > interval ? ( int ) ( delay / interval ) : 1 ; // figure out how many ticks need final int index = ( curSlot + ( ticks % maxTimers ) ) % maxTimers ; // figure out the wheel's index final int round = ( ticks - 1 ) / maxTimers ; // the round number of spin TimerTask task = new TimerTask ( round , run ) ; timerSlots [ index ] . add ( task ) ; return new Future ( this , index , task ) ; }
add a task