本文主要是介绍Java线程池理解,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
线程池理解
线程池的构造函数:
- corePoolSize: the number of threads to keep in the pool, even if they are idle, unless {@code allowCoreThreadTimeOut} is set(线程池中活跃的线程数,即使他们是空闲的,没有任务可以执行的,也不会销毁,除非设置 allowCoreThreadTimeOut)
- maximumPoolSize: the maximum number of threads to allow in the pool(线程池中允许的最大线程数量)
- keepAliveTime: when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.(当线程的数量大于核心线程数的时候,空闲的线程在他们销毁到等待新的任务到来,这段时间的最大值)
- unit: the time unit for the {@code keepAliveTime} argument(keepAliveTime 的时间单位)
- workQueue: the queue to use for holding tasks before they are executed. This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.(任务执行之前保存任务的队列,该队列将只保存由{@code execute}方法提交的{@code Runnable}任务)
- threadFactory: the factory to use when the executor creates a new thread(执行程序创建新线程时要使用的工厂)
- handler:the handler to use when execution is blocked because the thread bounds and queue capacities are reached(当执行因达到线程边界和队列容量而阻塞时要使用的处理程序)
这篇关于Java线程池理解的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!