|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.application.AbstractBean
org.jdesktop.application.TaskService
public class TaskService
The service for executing tasks
Methods descriptions are copied from ExecutorService
Constructor Summary | |
---|---|
TaskService(java.lang.String name)
Creates a new TaskService with default executor. |
|
TaskService(java.lang.String name,
java.util.concurrent.ExecutorService executorService)
Creates a new TaskService |
Method Summary | |
---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first. |
void |
execute(Task task)
Executes the task. |
java.lang.String |
getName()
Gets the name of this task service |
java.util.List<Task> |
getTasks()
Returns the list of tasks which are executing by this service |
boolean |
isShutdown()
Returns true if this executor has been shut down. |
boolean |
isTerminated()
Returns true if all tasks have completed following shut down. |
void |
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
java.util.List<java.lang.Runnable> |
shutdownNow()
Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. |
Methods inherited from class org.jdesktop.application.AbstractBean |
---|
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TaskService(java.lang.String name, java.util.concurrent.ExecutorService executorService)
TaskService
name
- the name of the task serviceexecutorService
- the executor to be used to run tasks.public TaskService(java.lang.String name)
TaskService
with default executor.
The default executor is a ThreadPoolExecutor with core pool size = 3,
maximum pool size = 10, threads live time = 1 second and queue of type
LinkedBlockingQueue
.
Method Detail |
---|
public final java.lang.String getName()
public void execute(Task task)
task
- the task to be executedpublic java.util.List<Task> getTasks()
public final void shutdown()
java.lang.SecurityException
- if a security manager exists and
shutting down this ExecutorService may manipulate
threads that the caller is not permitted to modify
because it does not hold RuntimePermission
("modifyThread"),
or the security manager's checkAccess method
denies access.public final java.util.List<java.lang.Runnable> shutdownNow()
There are no guarantees beyond best-effort attempts to stop
processing actively executing tasks. For example, typical
implementations will cancel via Thread.interrupt()
, so any
task that fails to respond to interrupts may never terminate.
java.lang.SecurityException
- if a security manager exists and
shutting down this ExecutorService may manipulate
threads that the caller is not permitted to modify
because it does not hold RuntimePermission
("modifyThread"),
or the security manager's checkAccess method
denies access.public final boolean isShutdown()
public final boolean isTerminated()
public final boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
java.lang.InterruptedException
- if interrupted while waiting
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |