# Class WorkerJob

java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.core.internal.jobs.InternalJob
org.eclipse.core.runtime.jobs.Job
org.eclipse.compare.internal.WorkerJob

All Implemented Interfaces:
  `Comparable<org.eclipse.core.internal.jobs.InternalJob>, IAdaptable`

public class WorkerJob extends Job

## Field Summary

### Fields inherited from class Job

`ASYNC_FINISH, BUILD, DECORATE, INTERACTIVE, LONG, NONE, RUNNING, SHORT, SLEEPING, WAITING`

### Fields inherited from class org.eclipse.core.internal.jobs.InternalJob

`manager`

## Constructor Summary

Constructors
Constructor
Description
`WorkerJob(String name)`

## Method Summary

Modifier and Type
Method
Description
`void`
`add(IRunnableWithProgress runnable)`
`protected IStatus`
`run(IProgressMonitor monitor)`
Executes this job.
`boolean`
`shouldRun()`
Returns whether this job should be run.

### Methods inherited from class Job

`addJobChangeListener, belongsTo, cancel, canceling, create, create, createSystem, createSystem, done, getJobGroup, getJobManager, getName, getPriority, getProperty, getResult, getRule, getState, getThread, isBlocking, isSystem, isUser, join, join, removeJobChangeListener, schedule, schedule, setJobGroup, setName, setPriority, setProgressGroup, setProperty, setRule, setSystem, setThread, setUser, shouldSchedule, sleep, toString, wakeUp, wakeUp, yieldRule`

### Methods inherited from class org.eclipse.core.internal.jobs.InternalJob

`compareTo`

### Methods inherited from class PlatformObject

`getAdapter`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### WorkerJob

public WorkerJob(String name)

## Method Details

### run

protected IStatus run(IProgressMonitor monitor)
Description copied from class: `Job`
Executes this job. Returns the result of the execution.

The provided monitor can be used to report progress and respond to cancellation. If the progress monitor has been canceled, the job should finish its execution at the earliest convenience and return a result status of severity `IStatus.CANCEL`. The singleton cancel status `Status.CANCEL_STATUS` can be used for this purpose. The monitor is only valid for the duration of the invocation of this method.

This method must not be called directly by clients. Clients should call `schedule`, which will in turn cause this method to be called.

Jobs can optionally finish their execution asynchronously (in another thread) by returning a result status of `Job.ASYNC_FINISH`. Jobs that finish asynchronously must specify the execution thread by calling `setThread`, and must indicate when they are finished by calling the method `done`.

Specified by:
  `run` in class `Job`
Parameters:
  `monitor` - the monitor to be used for reporting progress and responding to cancelation. The monitor is never `null`
Returns:
  resulting status of the run. The result must not be `null`
See Also:
  - `Job.ASYNC_FINISH`
  - `Job.done(IStatus)`

### shouldRun

public boolean shouldRun()
Description copied from class: `Job`
Returns whether this job should be run. If `false` is returned, this job will be discarded by the job manager without running.

This method is called immediately prior to calling the job's run method, so it can be used for last minute precondition checking before a job is run. This method must not attempt to schedule or change the state of any other job.

Clients may override this method. This default implementation always returns `true`.

Overrides:
  `shouldRun` in class `Job`
Returns:
  `true` if this job should be run and `false` otherwise

### add

public void add(IRunnableWithProgress runnable)