Package com.tagtraum.core.swing
Class Job
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- com.tagtraum.core.swing.Job
-
- All Implemented Interfaces:
Executor
,ExecutorService
public class Job extends AbstractExecutorService
Single-threaded job worker.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Job.Order
static class
Job.PriorityTaskFactory
static interface
Job.TaskFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
Job(String name, Job.TaskFactory taskFactory)
protected
Job(String name, Job.TaskFactory taskFactory, ExecutorService executorService)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, TimeUnit unit)
void
execute(Runnable command)
long
getCompletedTaskCount()
Returns the approximate total number of tasks that have completed execution.static Job
getDefaultJob()
Get default job (FIFO).ExecutorService
getExecutorService()
static Job
getLIFOJob()
Get LIFO job.String
getName()
static boolean
isDefaultJobThread()
Indicates whether we are in the static LIFO thread.boolean
isShutdown()
boolean
isTerminated()
protected <T> RunnableFuture<T>
newTaskFor(Runnable runnable, T value)
protected <T> RunnableFuture<T>
newTaskFor(Callable<T> callable)
static void
runASAP(Runnable runnable)
Run this asap, i.e.static void
runLater(Runnable runnable)
Run this later (FIFO) viagetDefaultJob()
.void
shutdown()
List<Runnable>
shutdownNow()
String
toString()
-
-
-
Constructor Detail
-
Job
protected Job(String name, Job.TaskFactory taskFactory, ExecutorService executorService)
-
Job
protected Job(String name, Job.TaskFactory taskFactory)
-
-
Method Detail
-
getName
public String getName()
-
getCompletedTaskCount
public long getCompletedTaskCount()
Returns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.- Returns:
- the number of tasks
- See Also:
ThreadPoolExecutor.getCompletedTaskCount()
-
getExecutorService
public ExecutorService getExecutorService()
-
isDefaultJobThread
public static boolean isDefaultJobThread()
Indicates whether we are in the static LIFO thread.- Returns:
- true or false
-
getDefaultJob
public static Job getDefaultJob()
Get default job (FIFO).- Returns:
- default job
-
getLIFOJob
public static Job getLIFOJob()
Get LIFO job.- Returns:
- LIFO job
-
runLater
public static void runLater(Runnable runnable)
Run this later (FIFO) viagetDefaultJob()
.- Parameters:
runnable
- runnable
-
runASAP
public static void runASAP(Runnable runnable)
Run this asap, i.e. viagetLIFOJob()
.- Parameters:
runnable
- runnable
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
- Overrides:
newTaskFor
in classAbstractExecutorService
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
- Overrides:
newTaskFor
in classAbstractExecutorService
-
shutdown
public void shutdown()
-
isShutdown
public boolean isShutdown()
-
isTerminated
public boolean isTerminated()
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
execute
public void execute(Runnable command)
-
-