Class 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.

    Kohsuke Kawaguchi
    • Constructor Detail

      • AtmostOneThreadExecutor

        public AtmostOneThreadExecutor​(ThreadFactory factory)
      • AtmostOneThreadExecutor

        public AtmostOneThreadExecutor()
    • Method Detail

      • shutdown

        public void shutdown()
      • shutdownNow

        public List<Runnable> shutdownNow()
      • isShutdown

        public boolean isShutdown()
      • isTerminated

        public boolean isTerminated()
      • execute

        public void execute​(@NonNull
                            Runnable command)