示例#1
0
 public static void main(String[] args) {
   // Prepares the listener.
   MySchedulerListener listener = new MySchedulerListener();
   // Prepares the task.
   MyTask task = new MyTask();
   // Creates the scheduler.
   Scheduler scheduler = new Scheduler();
   // Registers the listener.
   scheduler.addSchedulerListener(listener);
   // Schedules the task, once every minute.
   scheduler.schedule("* * * * *", task);
   // Starts the scheduler.
   scheduler.start();
   // Stays alive for five minutes.
   try {
     Thread.sleep(5L * 60L * 1000L);
   } catch (InterruptedException e) {;
   }
   // Stops the scheduler.
   scheduler.stop();
 }
示例#2
0
 public static final void destroy() {
   if (scheduler != null) scheduler.stop();
 }
 /** Shutdown the policy and clears the timer. */
 @Override
 public void shutdown(Client initiator) {
   cronScheduler.stop();
   super.shutdown(initiator);
 }