if (executor instanceof Service) {
Service service = (Service) executor;
service.stop();
}
else if (executor instanceof PooledExecutor) {
PooledExecutor pe = (PooledExecutor) executor;
pe.shutdownAfterProcessingCurrentlyQueuedTasks();
//pe.shutdownNow();
// Wait up to 5 seconds of the threads to shutdown..
pe.awaitTerminationAfterShutdown(1000*5);
}
else if (executor != null) {
log.warn("Don't know how to cleanly close down the given executor: " + executor
+ ". Consider deriving from this class to implement the Service interface to shut down cleanly");
}