org.infinispan.util.concurrent.WithinThreadExecutor Maven / Gradle / Ivy
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