public class DefaultScheduledExecutorService
extends java.lang.Object
implements java.util.concurrent.ScheduledExecutorService
Executors.newCachedThreadPool() and a
Executors.newScheduledThreadPool(int) to provide the functionality of
both in a single ScheduledExecutorService. This is necessary since
the ScheduledExecutorService uses an unbounded queue which makes it
impossible to create an unlimited number of threads on demand (as explained
in the ThreadPoolExecutor class javadoc.| Constructor and Description |
|---|
DefaultScheduledExecutorService() |
DefaultScheduledExecutorService(java.util.concurrent.ExecutorService executorService)
This instance will take over the lifecycle of the services.
|
DefaultScheduledExecutorService(java.util.concurrent.ExecutorService executorService,
java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
This instance will take over the lifecycle of the services.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
First calls
awaitTermination(long, TimeUnit) on the wrapped
ExecutorService and then awaitTermination(long, TimeUnit)
on the wrapped ScheduledExecutorService. |
void |
execute(java.lang.Runnable command) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
<V> java.util.concurrent.ScheduledFuture<V> |
schedule(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit) |
java.util.concurrent.ScheduledFuture<?> |
schedule(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit) |
java.util.concurrent.ScheduledFuture<?> |
scheduleAtFixedRate(java.lang.Runnable command,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit) |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit) |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task) |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task) |
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result) |
public DefaultScheduledExecutorService()
public DefaultScheduledExecutorService(java.util.concurrent.ExecutorService executorService)
executorService - public DefaultScheduledExecutorService(java.util.concurrent.ExecutorService executorService,
java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
executorService - scheduledExecutorService - public void shutdown()
shutdown in interface java.util.concurrent.ExecutorServicepublic java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorServicepublic boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination(long, TimeUnit) on the wrapped
ExecutorService and then awaitTermination(long, TimeUnit)
on the wrapped ScheduledExecutorService.awaitTermination in interface java.util.concurrent.ExecutorServicetrue if both Executors terminated, false
otherwisejava.lang.InterruptedExceptionpublic <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit in interface java.util.concurrent.ExecutorServicepublic <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
T result)
submit in interface java.util.concurrent.ExecutorServicepublic java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit in interface java.util.concurrent.ExecutorServicepublic <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorpublic java.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
schedule in interface java.util.concurrent.ScheduledExecutorServicepublic <V> java.util.concurrent.ScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit)
schedule in interface java.util.concurrent.ScheduledExecutorServicepublic java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
scheduleAtFixedRate in interface java.util.concurrent.ScheduledExecutorServicepublic java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
scheduleWithFixedDelay in interface java.util.concurrent.ScheduledExecutorService