All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.commons.util.concurrent.LifecycleRejectedExecutionHandler Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.commons.util.concurrent;

import java.util.concurrent.ThreadPoolExecutor;

import org.infinispan.commons.IllegalLifecycleStateException;

/**
 * A handler for rejected tasks that always throws a {@link IllegalLifecycleStateException}.
 * @author wburns
 * @since 11.0
 */
public class LifecycleRejectedExecutionHandler extends ThreadPoolExecutor.AbortPolicy {
   private LifecycleRejectedExecutionHandler() { }

   private static final LifecycleRejectedExecutionHandler INSTANCE = new LifecycleRejectedExecutionHandler();

   public static LifecycleRejectedExecutionHandler getInstance() {
      return INSTANCE;
   }

   @Override
   public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
      if (executor.isShutdown()) {
         throw new IllegalLifecycleStateException();
      }
      super.rejectedExecution(r, executor);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy