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

org.infinispan.util.concurrent.WithinThreadExecutor Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.util.concurrent;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * An executor that works within the current thread.
 *
 * @author Manik Surtani ([email protected])
 * @see Java Concurrency In Practice
 * @since 4.0
 */
public final class WithinThreadExecutor extends AbstractExecutorService {
   private volatile boolean shutDown = false;

   @Override
   public void execute(Runnable command) {
      command.run();
   }

   @Override
   public void shutdown() {
      shutDown = true;
   }

   @Override
   public List shutdownNow() {
      shutDown = true;
      return Collections.emptyList();
   }

   @Override
   public boolean isShutdown() {
      return shutDown;
   }

   @Override
   public boolean isTerminated() {
      return shutDown;
   }

   @Override
   public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
      return shutDown;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy