private void configure(final String name) {
   /*
    * All executors should be shutdown on application shutdown.
    */
   ShutdownHookManager.register(shutdownHook);
   /*
    * All threads should stop after 60 seconds of idle time
    */
   delegate.setKeepAliveTime(
       FIXED_THREAD_KEEPALIVE_TIMEOUT.longValue(), FIXED_THREAD_KEEPALIVE_TIMEOUT.getTimeUnit());
   /*
    * Fixes non starting with corepoolsize von 0 and not filled queue (Java Conurrency In Practice Chapter 8.3.1).
    * If this bug can occur, a exception would be thrown here.
    */
   delegate.allowCoreThreadTimeOut(true);
   /*
    * Named threads improve debugging.
    */
   delegate.setThreadFactory(new WrappedThreadFactory(name, delegate.getThreadFactory()));
 }
示例#2
0
 public static boolean isInterrupted(final Thread thread) {
   return thread.isInterrupted() || ShutdownHookManager.isShuttingDown();
 }
 private void unconfigure() {
   if (!isShutdown()) {
     ShutdownHookManager.unregister(shutdownHook);
   }
 }