Jobs are units of runnable work that can be scheduled to be run with the job manager. Once a job has completed, it can be scheduled to run again (jobs are reusable).
Jobs have a state that indicates what they are currently doing. When constructed, jobs start with a state value of NONE
. When a job is scheduled to be run, it moves into the WAITING
state. When a job starts running, it moves into the RUNNING
state. When execution finishes (either normally or through cancelation), the state changes back to NONE
.
A job can also be in the SLEEPING
state. This happens if a user calls Job.sleep() on a waiting job, or if a job is scheduled to run after a specified delay. Only jobs in the WAITING
state can be put to sleep. Sleeping jobs can be woken at any time using Job.wakeUp(), which will put the job back into the WAITING
state.
Jobs can be assigned a priority that is used as a hint about how the job should be scheduled. There is no guarantee that jobs of one priority will be run before all jobs of lower priority. The javadoc for the various priority constants provide more detail about what each priority means. By default, jobs start in the LONG
priority class.
@see IJobManager
@since 3.0