Java线程池理解
2021/11/2 14:10:00
本文主要是介绍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线程池理解的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)
- 2024-05-30【Java】百万数据excel导出功能如何实现
- 2024-05-30我们小公司,哪像华为一样,用得上IPD(集成产品开发)?
- 2024-05-30java excel上传--poi
- 2024-05-30安装笔记本应用商店的pycharm,再安排pandas等模块,说是没有打包工具?
- 2024-05-29java11新特性
- 2024-05-29哪些无用敏捷指标正在破坏敏捷转型?
- 2024-05-29鸿蒙原生应用再新丁!新华社 入局鸿蒙
- 2024-05-29设计模式 之 迭代器模式(Iterator)