public final class JobManager extends Object
Example code:
final Thread worker = new Thread("DisplayPreLoader") { public void run() { URL predictURI = Project.instance().getWritablePropertiesURI("save-name"); Progress job = JobManager.createJob("Job Title", predictURI, this, true); try { job.setProgress("Step 1"); ... job.setProgress("Step 2"); ... } catch (Exception ex) { ... job.ignoreTimings(); } finally { job.done(); } } }; worker.setPriority(Thread.MIN_PRIORITY); worker.start();
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private static Set<Progress> |
jobs
List of current jobs
|
private static List<WorkListener> |
listeners
List of listeners using thread safe list
|
private static org.slf4j.Logger |
log
The log stream
|
Modifier | Constructor and Description |
---|---|
private |
JobManager()
Prevent instantiation
|
Modifier and Type | Method and Description |
---|---|
static void |
addWorkListener(WorkListener li)
Add a listener to the list
|
static Progress |
createJob(String jobName)
Create a new Job that cannot be canceled.
|
static Progress |
createJob(String jobID,
String jobName,
Thread workerThread)
Create a new Job that can be canceled.
|
protected static void |
fireWorkProgressed(Progress job)
Inform the listeners that a title has changed.
|
static int |
getJobCount() |
static Iterator<Progress> |
iterator()
Accessor for the currently known jobs
|
static void |
removeWorkListener(WorkListener li)
Remove a listener from the list
|
private static List<WorkListener> listeners
private static final org.slf4j.Logger log
public static Progress createJob(String jobName)
jobName
- the name of the Jobpublic static Progress createJob(String jobID, String jobName, Thread workerThread)
jobID
- a unique identifier for the jobjobName
- the name of the JobworkerThread
- the thread on which this job runspublic static void addWorkListener(WorkListener li)
li
- the interested listenerpublic static void removeWorkListener(WorkListener li)
li
- the disinterested listenerpublic static Iterator<Progress> iterator()
public static int getJobCount()
protected static void fireWorkProgressed(Progress job)
job
- the job that has made progress