Class AtmostOneThreadExecutor

java.lang.Object
java.util.concurrent.AbstractExecutorService
hudson.remoting.AtmostOneThreadExecutor
All Implemented Interfaces:
Executor, ExecutorService

public class AtmostOneThreadExecutor extends AbstractExecutorService
ExecutorService that uses at most one executor.

Compared to Executors.newFixedThreadPool(1), this code will not keep the thread around if it's not doing anything, freeing up resources.

Since:
2.24
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • AtmostOneThreadExecutor

      public AtmostOneThreadExecutor(ThreadFactory factory)
    • AtmostOneThreadExecutor

      public AtmostOneThreadExecutor()
  • Method Details

    • shutdown

      public void shutdown()
    • shutdownNow

      @NonNull public List<Runnable> shutdownNow()
    • isShutdown

      public boolean isShutdown()
    • isTerminated

      public boolean isTerminated()
    • awaitTermination

      public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
      Throws:
      InterruptedException
    • execute

      public void execute(@NonNull Runnable command)