private static SingleThreadExecutor createSingleThreadExecutor(final String poolName, final int maxPendingTasks) {
        final ExecutorService singleThreadPool = ThreadPoolUtil.newBuilder() //
            .poolName(poolName) //
            .enableMetric(true) //
            .coreThreads(1) //
            .maximumThreads(1) //
            .keepAliveSeconds(60L) //
            .workQueue(new LinkedBlockingQueue<>(maxPendingTasks)) //
            .threadFactory(new NamedThreadFactory(poolName, true)) //
            .build();

        return new SingleThreadExecutor() {

            @Override
            public boolean shutdownGracefully() {
                return ExecutorServiceHelper.shutdownAndAwaitTermination(singleThreadPool);
            }

            @Override
            public boolean shutdownGracefully(final long timeout, final TimeUnit unit) {
                return ExecutorServiceHelper.shutdownAndAwaitTermination(singleThreadPool, unit.toMillis(timeout));
            }

            @Override
            public void execute(final Runnable command) {
                singleThreadPool.execute(command);
            }
        };
    }
Anti-gentleman is not against villains, we believe that you are
providing a single-thread executor.

@param singleThreadExecutorService a {@link ExecutorService} instance
jraft-core/src/main/java/com/alipay/sofa/jraft/util/concurrent/DefaultSingleThreadExecutor.java