org.apache.log4j.component.scheduler

## Class Scheduler

- java.lang.Object
- - java.lang.Thread
  - - org.apache.log4j.component.scheduler.Scheduler

- All Implemented Interfaces:
    Runnable

      public class Scheduler
      extends Thread

  A simple but still useful implementation of a Scheduler (in memory only).

  This implementation will work very well when the number of scheduled job is small, say less than 100 jobs. If a larger number of events need to be scheduled, than a better adapted data structure for the jobList can give improved performance.
  Author:
    Ceki

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Scheduler()` Create new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `changePeriod(Job job, long newPeriod)` Change the period of a job.
    `boolean` | `delete(Job job)` Delete the given job.
    `void` | `run()` Run scheduler.
    `void` | `schedule(Job job, long desiredTime)` Schedule a `Job` for execution at system time given by the `desiredTime` parameter.
    `void` | `schedule(Job job, long desiredTime, long period)` Schedule a `Job` for execution at system time given by the `desiredTime` parameter.
    `void` | `shutdown()` Shut down scheduler.

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Scheduler

          public Scheduler()

      Create new instance.

  - ### Method Detail

    - #### delete

          public boolean delete(Job job)

      Delete the given job.
      Parameters:
        `job` - job.
      Returns:
        true if the job could be deleted, and false if the job could not be found or if the Scheduler is about to shutdown in which case deletions are not permitted.

    - #### schedule

          public void schedule(Job job,
                      long desiredTime)

      Schedule a `Job` for execution at system time given by the `desiredTime` parameter.
      Parameters:
        `job` - job to schedule.
        `desiredTime` - desired time of execution.

    - #### schedule

          public void schedule(Job job,
                      long desiredTime,
                      long period)

      Schedule a `Job` for execution at system time given by the `desiredTime` parameter.

      The job will be rescheduled. It will execute with a frequency determined by the period parameter.
      Parameters:
        `job` - job to schedule.
        `desiredTime` - desired time of execution.
        `period` - repeat period.

    - #### changePeriod

          public boolean changePeriod(Job job,
                             long newPeriod)

      Change the period of a job. The original job must exist for its period to be changed.

      The method returns true if the period could be changed, and false otherwise.
      Parameters:
        `job` - job.
        `newPeriod` - new repeat period.
      Returns:
        true if period could be changed.

    - #### shutdown

          public void shutdown()

      Shut down scheduler.

    - #### run

          public void run()

      Run scheduler.
      Specified by:
        `run` in interface `Runnable`
      Overrides:
        `run` in class `Thread`

Copyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0

Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.