
Java线程池ThreadPool简单介绍
���������������������������������������������������������������������������������������������������������������������������������������������������CPU��������������������������������������������������������� ��������������������������������������������������������������������������������������������������������� ������������������������������������������������������������������������������������������������������������������������ ������������������������������������������������������������������������������ ������������������������������������������������������������������������������������������������������ ��������������������������������������������������������������������������������������������������������� ��������������������������������������������������������������� SynchronousQueue��������������������������������������������������������������������������������������������������������������������������������� LinkedBlockingQueue��������������������������������������������������������������������������������������������������� ArrayBlockingQueue��������������������������������������������������������������������������������������������������� DelayQueue������������������ AbortPolicy��������������������������������� DiscardPolicy������������������������ DiscardOldestPolicy������������������������������������������������������ CallerRunsPolicy������������������������������������������������������ FixedThreadPool���������������������������������������������������������������������
发布日期:2021-05-12 16:26:15
浏览次数:31
分类:精选文章
本文共 4067 字,大约阅读时间需要 13 分钟。
���������������
������������������
���������������Java������������������������������������������
������������������
���������������������
public ThreadPoolExecutor( int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueueworkQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) { if (corePoolSize < 0 || maximumPoolSize <= 0 || maximumPoolSize < corePoolSize || keepAliveTime < 0) { throw new IllegalArgumentException(); } if (workQueue == null || threadFactory == null || handler == null) { throw new NullPointerException(); } // ���������������������...}
���������������������������
- corePoolSize���������������������������������������
- maximumPoolSize������������������������������ ��������������� = ��������������� + ���������������������
- keepAliveTime���������������������������������������
- unit���������������������
- workQueue������������������������������
- threadFactory������������������������������
- handler���������������������������
������������������
corePoolSize
���������������������������������������������������workQueue
���������������maximumPoolSize
���������������������������������������������������handler
���������������������������������types
Delayed
���������������������������������������������������������������
���������������������
���������������
public static ExecutorService newFixedThreadPool(int nThreads) { return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());}
- CachedThreadPool������������������������������������������������������������������
- SingleThreadExecutor���������������������������������������
- ScheduledThreadPool���������������������������������������������
- ���������������������������������I/O������������������������
CachedThreadPool
���������������������������������FixedThreadPool
���
public static ExecutorService newCachedThreadPool() { return new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());}
public static ExecutorService newSingleThreadExecutor() { return new FinalizableDelegatedExecutorService(new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()));}
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { return new ScheduledThreadPoolExecutor(corePoolSize);}
���������������������������
������������������������������������������������������������������������������������
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2025年05月01日 14时39分24秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
MySQL----基础及常用命令
2021-05-12
模拟集成:MOS管的工作区小误区(简单版)
2021-05-12
flink启动(二)
2021-05-12
前端开发进阶手册.pdf
2021-05-12
110.无限叠卡特效
2021-05-12
软件架构设计和MESH经验之谈
2021-05-12
redis持久化分析
2021-05-12
复杂指针解析
2021-05-12
打开word时424错误
2021-05-12
如何添加开机自启项
2021-05-12
微服务架构编码构建
2021-05-12
❤️一个18k运维项目经验这样做的,offer到碗里来❤️
2021-05-12
关于宝塔面板安装的mysql用Navicat连接出现2003的错误解决
2021-05-12
Windows2016 FTP用户隔离
2021-05-12
js传入参数是中文的时候出现 “******”未定义错误
2021-05-12
responded with a status of 404 ()
2021-05-12
【MySQL】MySQL数据库文件
2021-05-12
吴恩达机器学习课程笔记(英文授课) Lv.1 新手村(回归)
2021-05-12
pair的用法
2021-05-12