参数

reactor-core-2.0.8.RELEASE-sources.jar!/reactor/core/dispatch/ThreadPoolExecutorDispatcher.java


/**
     * Create a new {@literal ThreadPoolExecutorDispatcher} with the given size, backlog, name, and {@link
     * java.util.concurrent.RejectedExecutionHandler}.
     *
     * @param poolSize
     *         the pool size
     * @param backlog
     *         the backlog size
     * @param threadName
     *         the name prefix to use when creating threads
     * @param rejectedExecutionHandler
     *         the {@code RejectedExecutionHandler} to use when jobs can't be submitted to the thread pool
     */
    public ThreadPoolExecutorDispatcher(int poolSize,
                                        int backlog,
                                        String threadName,
                                        BlockingQueue<Runnable> workQueue,
                                        RejectedExecutionHandler rejectedExecutionHandler) {
        super(poolSize, backlog);
        this.workQueue = workQueue;
        this.executor = new ThreadPoolExecutor(
                poolSize,
                poolSize,
                0L,
                TimeUnit.MILLISECONDS,
                workQueue,
                new NamedDaemonThreadFactory(threadName, getContext()),
                rejectedExecutionHandler
        );
    }

配置文件的size,对应ThreadPoolExecutor的corePoolSize以及maximumPoolSize

自定义ThreadPoolExecutorDispatcher

Dispatcher dispatcher = new ThreadPoolExecutorDispatcher(5, 2048,"dispatcherGroup",
                new LinkedBlockingQueue<Runnable>(2048),
                new ThreadPoolExecutor.DiscardOldestPolicy());
EventBus eventBus = EventBus.create(eventBusEnv,dispatcher);

codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...