|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ThreadPool
Method Summary | ||
---|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
|
|
void |
execute(java.lang.Runnable command)
|
|
int |
getActiveCount()
Returns the approximate number of threads that are actively executing tasks. |
|
int |
getPoolSize()
Returns the current number of threads in the pool. |
|
int |
getSchedulerActiveCount()
|
|
int |
getSchedulerPoolSize()
|
|
boolean |
isStarted()
Returns true if the thread pool has started. |
|
|
schedule(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a ScheduledFuture that becomes enabled after the given delay. |
|
java.util.concurrent.ScheduledFuture<?> |
schedule(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay. |
|
java.util.concurrent.ScheduledFuture<?> |
schedule(java.lang.Runnable command,
TimeValue delay)
|
|
java.util.concurrent.ScheduledFuture<?> |
scheduleAtFixedRate(java.lang.Runnable command,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is executions will commence after initialDelay then initialDelay+period, then initialDelay + 2 * period, and so on. |
|
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next. |
|
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
TimeValue interval)
|
|
void |
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
|
void |
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. |
|
|
submit(java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task. |
|
|
submit(java.util.concurrent.Callable<T> task,
FutureListener<T> listener)
|
|
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future representing that task. |
|
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task,
FutureListener<?> listener)
|
|
|
submit(java.lang.Runnable task,
T result)
Submits a Runnable task for execution and returns a Future representing that task. |
|
|
submit(java.lang.Runnable task,
T result,
FutureListener<T> listener)
|
Method Detail |
---|
int getPoolSize()
int getActiveCount()
int getSchedulerPoolSize()
int getSchedulerActiveCount()
boolean isStarted()
void 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.
void shutdown()
boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
java.lang.InterruptedException
void execute(java.lang.Runnable command)
<T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();
Note: The Executors
class includes a set of methods
that can convert some other common closure-like objects,
for example, PrivilegedAction
to
Callable
form so they can be submitted.
task
- the task to submit
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if the task is null<T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)
task
- the task to submitresult
- the result to return
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if the task is nulljava.util.concurrent.Future<?> submit(java.lang.Runnable task)
task
- the task to submit
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if the task is null<T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task, FutureListener<T> listener)
<T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result, FutureListener<T> listener)
java.util.concurrent.Future<?> submit(java.lang.Runnable task, FutureListener<?> listener)
java.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
command
- the task to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameter
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if command is null<V> java.util.concurrent.ScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
callable
- the function to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameter
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if callable is nulljava.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
command
- the task to executeinitialDelay
- the time to delay first executionperiod
- the period between successive executionsunit
- the time unit of the initialDelay and period parameters
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if command is null
java.lang.IllegalArgumentException
- if period less than or equal to zerojava.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
command
- the task to executeinitialDelay
- the time to delay first executiondelay
- the delay between the termination of one
execution and the commencement of the nextunit
- the time unit of the initialDelay and delay parameters
java.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for execution
java.lang.NullPointerException
- if command is null
java.lang.IllegalArgumentException
- if delay less than or equal to zerojava.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command, TimeValue delay)
java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, TimeValue interval)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |