Class KScheduler2

java.lang.Object
com.kheops.util.KScheduler2

public class KScheduler2 extends Object
A KScheduler executes scheduled jobs (notifications). Clients simply register with the scheduler to be notified sometime in the future. The job can be done only once or be recurrent. The clients must implement the interface KSchedulerClient. The scheduler must be explicitly started.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new KScheduler object.
    Constructs a new KScheduler object using the specified string as the name of the thread of the scheduler.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addJob(KSchedulerClient client, int jobId, long delay, boolean recurrent)
    Adds a new job in the scheduler.
    void
    Removes all jobs in the scheduler.
    void
    removeJob(KSchedulerClient client, int jobId)
    Removes a job for the specified client with the specified job id.
    void
    Starts the scheduler thread if not already started.
    void
    Stops the scheduler thread if started.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KScheduler2

      public KScheduler2()
      Constructs a new KScheduler object.
    • KScheduler2

      public KScheduler2(String name)
      Constructs a new KScheduler object using the specified string as the name of the thread of the scheduler.
      Parameters:
      name - name to use as athe threda name
  • Method Details

    • start

      public void start()
      Starts the scheduler thread if not already started.
    • stop

      public void stop()
      Stops the scheduler thread if started.
    • addJob

      public void addJob(KSchedulerClient client, int jobId, long delay, boolean recurrent)
      Adds a new job in the scheduler. The specified client will be notified when the specified delay expires. If the recurrent flag is true, yhen the client will be notified recurrently, using the specified delay as the period. A same client can add more than jobs, as long as the jobs are identified using different jobId's.
      Parameters:
      client - the client to notify
      jobId - a number assigned to the job. Must be unique for a given client.
      delay - number of milliseconds to wait until the client is notified by the scheduler
      recurrent - if true, the client will be notified recurrently, once every delay millisecondes. Otherwise, the client will be notified only once.
    • removeJob

      public void removeJob(KSchedulerClient client, int jobId)
      Removes a job for the specified client with the specified job id.
      Parameters:
      client - the client associated with the job
      jobId - the id of the job to remove
    • removeAllJobs

      public void removeAllJobs()
      Removes all jobs in the scheduler.