public abstract class JobBase extends java.lang.Object implements Job
Job classes can only be accessed from two threads: a) the job thread, and b) the JobManager thread. The JobManager thread only accesses the status and stopRequested properties of the job. Job implementation classes can also access these properties at any time, without the need for additional synchronization.
Job classes can also define additional properties which they use internally. The JobManager thread will never access these properties.
Modifier and Type | Field and Description |
---|---|
protected JobStatus |
status
Job status.
|
protected boolean |
stopRequested
Set to true when stop is requested.
|
Constructor and Description |
---|
JobBase() |
Modifier and Type | Method and Description |
---|---|
JobStatus |
getStatus()
Returns the current job status.This method is called by the Job Manager which runs in a
different thread.
|
void |
run()
Default run() implementation does not do anything.
|
void |
stop()
Requests the job to stop.
|
protected final JobStatus status
protected volatile boolean stopRequested
public JobStatus getStatus()
The status object is owned by the job implementation. The run() method should update the status object in a thread-safe manner.
public void stop()
The implementation is assumed to set the internal flag, in a thread-safe manner. The run() method implementation is assumed to check the flag periodically, between units of work.
If the job does not stop after configurable time interval, the Job Manager may terminate the job thread.