public synchronized void run ( ) { while ( ! shutdown ) { if ( jobList . isEmpty ( ) ) { linger ( ) ; } else { ScheduledJobEntry sje = ( ScheduledJobEntry ) jobList . get ( 0 ) ; long now = System . currentTimeMillis ( ) ; if ( now >= sje . desiredExecutionTime ) { executeInABox ( sje . job ) ; jobList . remove ( 0 ) ; if ( sje . period > 0 ) { sje . desiredExecutionTime = now + sje . period ; schedule ( sje ) ; } } else { linger ( sje . desiredExecutionTime - now ) ; } } } // clear out the job list to facilitate garbage collection jobList . clear ( ) ; jobList = null ; System . out . println ( "Leaving scheduler run method" ) ; }
Run scheduler .