身安不如心安,屋宽不如心宽 。

ES中threadpool的direct类型

Elasticsearch | 作者 zhangg7723 | 发布于2018年07月26日 | 阅读数:2361

在阅读ES2.1源码的过程中发现thread pool的类型有四种

Snipaste_2018-07-26_09-26-32.png

 
cached,fixed,scaling这三种类型在官网上都能查到,direct是什么类型呢?
 
已邀请:

rochy - rochy_he

赞同来自: zhangg7723

参考:https://www.felayman.com/artic ... .html
 direct
此类线程是一种不支持关闭的线程,就意味着一旦使用,则会一直存活下去.

fixed
此类线程池拥有固定数量的线程来处理请求,在没有空闲线程时请求将被挂在队列中(可选配)

scaling
此类线程池拥有的线程数量是动态的。这个数字介于core和max参数的配置之间变化

kennywu76 - Wood

赞同来自:

Direct类型表示用当前线程执行提交的任务,并且该线程不能被关闭。我的理解是比较轻量级或者需要单线程执行的任务提交给这个executor。 参考代码里该执行器的注释:
   /**
* Returns an {@link ExecutorService} that executes submitted tasks on the current thread. This executor service does not support being
* shutdown.
*
* @return an {@link ExecutorService} that executes submitted tasks on the current thread
*/
public static ExecutorService newDirectExecutorService() {
return DIRECT_EXECUTOR_SERVICE;
}



要回复问题请先登录注册