com.twitter.common.util.concurrent
Class ExecutorServiceShutdown

java.lang.Object
  extended by com.twitter.common.util.concurrent.ExecutorServiceShutdown
All Implemented Interfaces:
Command, ExceptionalCommand<RuntimeException>

public class ExecutorServiceShutdown
extends Object
implements Command

An implementation of the graceful shutdown sequence recommended by ExecutorService.


Constructor Summary
ExecutorServiceShutdown(ExecutorService executor, Amount<Long,Time> gracePeriod)
          Creates a new ExecutorServiceShutdown command that will try to gracefully shut down the given executor when executed.
 
Method Summary
 void execute()
          Performs a unit of work, possibly throwing E in the process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutorServiceShutdown

public ExecutorServiceShutdown(ExecutorService executor,
                               Amount<Long,Time> gracePeriod)
Creates a new ExecutorServiceShutdown command that will try to gracefully shut down the given executor when executed. If the supplied grace period is less than or equal to zero the executor service will be asked to shut down but no waiting will be done after these requests.

Parameters:
executor - The executor service this command should shut down when executed.
gracePeriod - The maximum time to wait after a shutdown request before continuing to the next shutdown phase.
Method Detail

execute

public void execute()
Description copied from interface: ExceptionalCommand
Performs a unit of work, possibly throwing E in the process.

Specified by:
execute in interface ExceptionalCommand<RuntimeException>