<!-- 配置时未指定线程相关配置 -->
<dubbo:protocol name="dubbo" port="${dubbo.port}" />
<!-- 则等同于以下配置 -->
<dubbo:protocol name="dubbo" dispatcher="all" threadpool="fixed" threads="200" />
附上线程池源码
public class FixedThreadPool implements ThreadPool {
public Executor getExecutor(URL url) {
String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME);
int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
int queues = url.getParameter(Constants.QUEUES_KEY, Constants.DEFAULT_QUEUES);
return new ThreadPoolExecutor(threads, threads, 0, TimeUnit.MILLISECONDS,
queues == 0 ? new SynchronousQueue<Runnable>() :
(queues < 0 ? new LinkedBlockingQueue<Runnable>()
: new LinkedBlockingQueue<Runnable>(queues)),
new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url));
}
}
这样默认会启用 200 个线程,按照正常对线程池分配线程数的逻辑,不应该配置这么多啊。我想知道为什么默认要设置为200