Interface IJob
- All Superinterfaces:
Runnable
- All Known Implementing Classes:
AbstractJob,Job,RunnableJobAdapter
A unit of work that can be run synchronously or asynchronously, paused, resumed, cancelled and monitored.
-
Method Summary
Modifier and TypeMethodDescriptioncancel()Interrupts the run thread and cancels the child job; does nothing unless this job is running and not yet cancelled.Returns the time this job instance was cancelled.getChild()Returns the thread-local child job of this one while this job is running.Returns the time this job instance was created.Returns the last exception thrown while running.Returns the time this job finished running.getName()Returns the name assigned to this job or its default name if one was not assigned.Returns the thread-local job that ran this one while this job is running.Returns the time this job was paused ornullif this job is not currently paused.longReturns the number of milliseconds this job was (or has been) running for or zero (0) if it hasn't yet started running.Returns the time this job was (or has been) running in long form as a human readable string (2 Years, 1 Second, 12 Millisecond) ornullif it hasn't yet started running.getRunningTimeAsString(boolean shortForm) Returns the time this job was (or has been) running as a human readable string in long form (2 Years, 1 Second, 12 Millisecond) or short form (2y 1s 12ms) ornullif it hasn't yet started running.Returns the thread currently executing this job ornullif the job is not running.Returns the time this job instance started running.getUuid()Returns the universally unique identifier (UUID) for this job.booleanReturnstrueif this job was cancelled.booleanisFailed()Returnstrueif this job has completed unsuccessfully.booleanReturnstrueif this job has finished running.booleanisPaused()Returnstrueif this job is currently paused.booleanReturnstrueif this job is currently running.pause()resume()Lets a paused job continue; does nothing if it is not paused.voidrun()Executes this job in the current thread.runAsync()Executes this job in a new thread.Assigns a new name to this job.Waits for this job to complete.waitUntilFinished(long timeout) Waits up totimeoutmilliseconds for this job to complete or throwsInterruptedException.Waits for this job to start.waitUntilStarted(long timeout) Waits up totimeoutmilliseconds for this job to start or throwsInterruptedException.
-
Method Details
-
getParent
IJob getParent()Returns the thread-local job that ran this one while this job is running. -
getChild
IJob getChild()Returns the thread-local child job of this one while this job is running. -
getUuid
UUID getUuid()Returns the universally unique identifier (UUID) for this job. -
getName
String getName()Returns the name assigned to this job or its default name if one was not assigned. -
setName
Assigns a new name to this job. -
getCreatedOn
Date getCreatedOn()Returns the time this job instance was created. -
getStartedOn
Date getStartedOn()Returns the time this job instance started running. -
getCancelledOn
Date getCancelledOn()Returns the time this job instance was cancelled. -
isCancelled
boolean isCancelled()Returnstrueif this job was cancelled. -
getPausedOn
Date getPausedOn()Returns the time this job was paused ornullif this job is not currently paused. -
isPaused
boolean isPaused()Returnstrueif this job is currently paused. -
getFinishedOn
Date getFinishedOn()Returns the time this job finished running. -
isFinished
boolean isFinished()Returnstrueif this job has finished running. -
getException
DataException getException()Returns the last exception thrown while running. -
isFailed
boolean isFailed()Returnstrueif this job has completed unsuccessfully. -
getRunThread
Thread getRunThread()Returns the thread currently executing this job ornullif the job is not running. -
isRunning
boolean isRunning()Returnstrueif this job is currently running. -
getRunningTime
long getRunningTime()Returns the number of milliseconds this job was (or has been) running for or zero (0) if it hasn't yet started running. -
getRunningTimeAsString
String getRunningTimeAsString()Returns the time this job was (or has been) running in long form as a human readable string (2 Years, 1 Second, 12 Millisecond) ornullif it hasn't yet started running. -
getRunningTimeAsString
Returns the time this job was (or has been) running as a human readable string in long form (2 Years, 1 Second, 12 Millisecond) or short form (2y 1s 12ms) ornullif it hasn't yet started running. -
pause
IJob pause() -
resume
IJob resume()Lets a paused job continue; does nothing if it is not paused. -
cancel
IJob cancel()Interrupts the run thread and cancels the child job; does nothing unless this job is running and not yet cancelled. -
run
void run()Executes this job in the current thread. This method blocks until the transfer either completes successfully or fails for any reason. -
runAsync
IJob runAsync()Executes this job in a new thread. This method does not block. -
waitUntilStarted
Waits for this job to start.- Returns:
- Throws:
InterruptedException
-
waitUntilStarted
Waits up totimeoutmilliseconds for this job to start or throwsInterruptedException.- Returns:
- Throws:
InterruptedException
-
waitUntilFinished
Waits for this job to complete.- Returns:
- Throws:
InterruptedException
-
waitUntilFinished
Waits up totimeoutmilliseconds for this job to complete or throwsInterruptedException.- Returns:
- Throws:
InterruptedException
-