if( nextRun < 0 )
{
return;
}
System.out.println( "Next run at: " + new DateTime( nextRun ) );
timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
if( scheduleHandler == null )
{
dispatchHandler();
}
}
else
{
ScheduleTime first = timingQueue.first();
long nextRun = schedule.nextRun( now );
if( nextRun < 0 )
{
return;
}
System.out.println( "Next run at: " + new DateTime( nextRun ) );
timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
ScheduleTime newFirst = timingQueue.first();
if( !first.equals( newFirst ) )
{
// We need to restart the managementThread, which is currently waiting for a 'later' event to
// occur than the one that was just scheduled.
scheduleHandler.future.cancel( true );