public class ThreadPool extends AbstractExecutorService implements ScheduledExecutorService
| Constructor and Description |
|---|
ThreadPool(int max,
boolean daemon) |
ThreadPool(int max,
boolean daemon,
String prefix) |
ThreadPool(int max,
boolean daemon,
String prefix,
Thread.UncaughtExceptionHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long time,
TimeUnit unit) |
void |
execute(Runnable command) |
boolean |
isShutdown() |
boolean |
isTerminated() |
<V> ScheduledFuture<V> |
schedule(Callable<V> callable,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
schedule(Runnable command,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleAtRandomRate(Runnable command,
long initialDelay,
long lowPeriod,
long highPeriod,
TimeUnit unit)
Schedules a task which executes with a randomly selected rate, for
applying jitter.
|
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit) |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitpublic ThreadPool(int max,
boolean daemon)
max - the maximum allowed number of threadsdaemon - pass true for all threads to be daemon -- they won't
prevent the JVM from exitingpublic ThreadPool(int max,
boolean daemon,
String prefix)
max - the maximum allowed number of threadsdaemon - pass true for all threads to be daemon -- they won't
prevent the JVM from exitingprefix - thread name prefix; default used if nullpublic ThreadPool(int max,
boolean daemon,
String prefix,
Thread.UncaughtExceptionHandler handler)
max - the maximum allowed number of threadsdaemon - pass true for all threads to be daemon -- they won't
prevent the JVM from exitingprefix - thread name prefix; default used if nullhandler - optional uncaught exception handlerpublic void execute(Runnable command) throws RejectedExecutionException
execute in interface ExecutorRejectedExecutionExceptionpublic ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
schedule in interface ScheduledExecutorServicepublic <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
schedule in interface ScheduledExecutorServicepublic ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
scheduleAtFixedRate in interface ScheduledExecutorServicepublic ScheduledFuture<?> scheduleAtRandomRate(Runnable command, long initialDelay, long lowPeriod, long highPeriod, TimeUnit unit)
lowPeriod - low end of the random period rangehighPeriod - high end of the random period rangepublic ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
scheduleWithFixedDelay in interface ScheduledExecutorServicepublic void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic boolean awaitTermination(long time,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedExceptionCopyright © 2006–2015 Cojen. All rights reserved.