wt.jmx.core
Class SharedScheduledExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by wt.jmx.core.SharedScheduledExecutor
All Implemented Interfaces:
Executor, ExecutorService, ScheduledExecutorService

public class SharedScheduledExecutor
extends AbstractExecutorService
implements ScheduledExecutorService

This utility is largely a normal, drop in ScheduledExecutorService implementation. It assumes that all instances sharing a given name and daemon flag should share a single ScheduledThreadPoolExecutor. This prevents the common circumstance wherein many bodies of code create their own ScheduledExecutorService or Timer and thus their own thread or thread pool when their load does not justify this -- thus wasting threads.

This is not a full ScheduledExecutorService implementation, however, in that shutdownNow(), awaitTermination(), and isTerminated() do not behave as described in the ScheduledExecutorService documentation. Please use ScheduledThreadPoolExecutor instead if this is an issue.

Supported API: true

Extendable: false


Constructor Summary
SharedScheduledExecutor(String name, boolean daemon)
          Constructor.
 
Method Summary
 void execute(Runnable command)
          Method required by ScheduledExecutorService interface

Supported API: true
 boolean isShutdown()
          Method required by ScheduledExecutorService interface

Supported API: true
<V> ScheduledFuture<V>
schedule(Callable<V> callable, long delay, TimeUnit unit)
          Method required by ScheduledExecutorService interface

Supported API: true
 ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
          Method required by ScheduledExecutorService interface

Supported API: true
 ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
          Method required by ScheduledExecutorService interface

Supported API: true
 ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
          Method required by ScheduledExecutorService interface

Supported API: true
 void shutdown()
          Method required by ScheduledExecutorService interface

Supported API: true
<T> Future<T>
submit(Callable<T> task)
          Overrides AbstractExecutorService method with same signature.
 Future<?> submit(Runnable task)
          Overrides AbstractExecutorService method with same signature.
<T> Future<T>
submit(Runnable task, T result)
          Overrides AbstractExecutorService method with same signature.
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.ExecutorService
invokeAll, invokeAll, invokeAny, invokeAny
 

Constructor Detail

SharedScheduledExecutor

public SharedScheduledExecutor(String name,
                               boolean daemon)
Constructor.

Supported API: true

Method Detail

schedule

public ScheduledFuture<?> schedule(Runnable command,
                                   long delay,
                                   TimeUnit unit)
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
schedule in interface ScheduledExecutorService

schedule

public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                                       long delay,
                                       TimeUnit unit)
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
schedule in interface ScheduledExecutorService

scheduleAtFixedRate

public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
                                              long initialDelay,
                                              long period,
                                              TimeUnit unit)
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
scheduleAtFixedRate in interface ScheduledExecutorService

scheduleWithFixedDelay

public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
                                                 long initialDelay,
                                                 long delay,
                                                 TimeUnit unit)
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
scheduleWithFixedDelay in interface ScheduledExecutorService

shutdown

public void shutdown()
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
shutdown in interface ExecutorService

isShutdown

public boolean isShutdown()
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
isShutdown in interface ExecutorService

submit

public <T> Future<T> submit(Callable<T> task)
Overrides AbstractExecutorService method with same signature. Method required by ScheduledExecutorService interface.

Supported API: true

Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService

submit

public <T> Future<T> submit(Runnable task,
                            T result)
Overrides AbstractExecutorService method with same signature. Method required by ScheduledExecutorService interface.

Supported API: true

Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService

submit

public Future<?> submit(Runnable task)
Overrides AbstractExecutorService method with same signature. Method required by ScheduledExecutorService interface.

Supported API: true

Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService

execute

public void execute(Runnable command)
Method required by ScheduledExecutorService interface

Supported API: true

Specified by:
execute in interface Executor