@ Override public Time scheduleAlarm ( final int offset , final EventHandler < Alarm > handler ) { final Time alarm = new ClientAlarm ( this . timer . getCurrent ( ) + offset , handler ) ; if ( LOG . isLoggable ( Level . FINEST ) ) { final int eventQueueLen ; synchronized ( this . schedule ) { eventQueueLen = this . numClientAlarms ; } LOG . log ( Level . FINEST , "Schedule alarm: {0} Outstanding client alarms: {1}" , new Object [ ] { alarm , eventQueueLen } ) ; } synchronized ( this . schedule ) { if ( this . isClosed ) { throw new IllegalStateException ( "Scheduling alarm on a closed clock" ) ; } if ( alarm . getTimestamp ( ) > this . lastClientAlarm ) { this . lastClientAlarm = alarm . getTimestamp ( ) ; } assert this . numClientAlarms >= 0 ; ++ this . numClientAlarms ; this . schedule . add ( alarm ) ; this . schedule . notify ( ) ; } return alarm ; }
Schedule a new Alarm event in offset milliseconds into the future and supply an event handler to be called at that time .