Package com.kheops.util
Class KScheduler
java.lang.Object
java.lang.Thread
com.kheops.util.KScheduler
- All Implemented Interfaces:
- Runnable
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.- 
Nested Class SummaryNested classes/interfaces inherited from class java.lang.ThreadThread.Builder, Thread.State, Thread.UncaughtExceptionHandler
- 
Field SummaryFields inherited from class java.lang.ThreadMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddJob(KSchedulerClient client, int jobId, long delay, boolean recurrent) Adds a new job in the scheduler.voidcallMeEveryNSeconds(KSchedulerClient client, int jobId, long delay) Deprecated.Use addJob method instead.voidcallMeNow(KSchedulerClient client, int jobId) Deprecated.Use addJob method instead.static voidclose()Closes the scheduler.static KSchedulerRetrieves the unique instance (singleton) of KScheduler.voidremoveJob(KSchedulerClient client, int jobId) Removes a job for the specified client with the specified job id.voidrun()Overrides the run methodvoidstopCallingMe(KSchedulerClient client, int jobId) Deprecated.Use removeJob method instead.Methods inherited from class java.lang.ThreadactiveCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
- 
Constructor Details- 
KSchedulerDeprecated.KScheduler should be used as a Singleton. Use getInstance instead to obtain the unique instance of KScheduler.Constructs a new KScheduler object.
 
- 
- 
Method Details- 
getInstanceRetrieves the unique instance (singleton) of KScheduler.- Returns:
- the KScheduler Instance
 
- 
runpublic void run()Overrides the run method
- 
addJobAdds 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.
 
- 
callMeEveryNSecondsDeprecated.Use addJob method instead.Registers the specified client to be notified recurrently using the specified period.- Parameters:
- client- the client to notify
- jobId- the id of the job
- delay- the number of seconds between each notification
 
- 
callMeNowDeprecated.Use addJob method instead.Registers the specified client to be notified once as soon as possible. Can be useful to schedule jobs when the scheduler is not started yet. These jobs will be executed one after the other when the scheduler gets started.- Parameters:
- client- the client to notify
- jobId- the id of the job
 
- 
removeJobRemoves 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
 
- 
stopCallingMeDeprecated.Use removeJob method instead.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
 
- 
closepublic static void close()Closes the scheduler.
 
-