This
class
extends ThreadPoolExecutor to implement the
methods of the ScheduledExecutorService interface
to allow tasks to be submitted for execution once or repeatedly at
some scheduled time in the future. Instances of this class are
usually obtained through the static factory methods of the
Executors utility class. You can also explicitly
create one with the ScheduledThreadPoolExecutors(
) constructor.
ScheduledThreadPoolExecutor always creates its own
unbounded work queue, which means that you cannot pass a queue to the
constructor. Also, there is no need to specify a
maximumPoolSize since this configuration
parameter is irrelevant with unbounded queues.
Note that tasks submitted to a
ScheduledThreadPoolExecutor are not guaranteed to
run at the scheduled time. That is the time at which they first
become eligible to run. If all threads are busy with other tasks,
however, eligible tasks may get queued up to run later.
This class provides functionality similar to
java.util.Timer but adds multithreaded capability
and the ability to work with Callable and
Future objects.

public class ScheduledThreadPoolExecutor extends ThreadPoolExecutor
implements ScheduledExecutorService {
// Public Constructors
public ScheduledThreadPoolExecutor(int corePoolSize);
public ScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory);
public ScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler);
public ScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory,
RejectedExecutionHandler handler);
// Public Instance Methods
public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy( );
public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy( );
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean value);
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean value);
// Methods Implementing Executor
public void execute(Runnable command);
// Methods Implementing ExecutorService
public void shutdown( );
public java.util.List<Runnable> shutdownNow( );
public Future<?> submit(Runnable task);
public <T> Future<T> submit(Callable<T> task);
public <T> Future<T> submit(Runnable task, T result);
// Methods Implementing ScheduledExecutorService
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay,
long period, TimeUnit unit);
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay,
long delay, TimeUnit unit);
// Public Methods Overriding ThreadPoolExecutor
public BlockingQueue<Runnable> getQueue( );
public boolean remove(Runnable task);
}