查自API文档:
ExecutorServicethreadPool=Executors.newFixedThreadPool(3);
newFixedThreadPool:
-
Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. At any point, at most
nThreads threads will be active processing tasks. If additional tasks are submitted when all threads are active, they will wait in the queue until a thread is available. If any thread terminates due to a failure during execution prior
to shutdown, a new one will take its place if needed to execute subsequent tasks. The threads in the pool will exist until it is explicitly
shutdown
.
newCachedThreadPool:
-
Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available.
These pools will typically improve the performance of programs that execute many short-lived asynchronous tasks. Calls to
execute will reuse previously constructed threads if available. If no existing thread is available, a new thread will be created and added to the pool. Threads that have not been used for sixty seconds are terminated and removed from the cache. Thus,
a pool that remains idle for long enough will not consume any resources. Note that pools with similar properties but different details (for example, timeout parameters) may be created using
ThreadPoolExecutor
constructors.
newSingleThreadExecutor:
-
Creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution prior
to shutdown, a new one will take its place if needed to execute subsequent tasks.) Tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time. Unlike the otherwise equivalent
newFixedThreadPool(1) the returned executor is guaranteed not to be reconfigurable to use additional threads.
newScheduledThreadPool:
分享到:
相关推荐
java 线程池 完整 源码 java 线程池 完整 源码
简单的线程池程序+中文文档 包结构: com.tangkai.threadpool --SimpleThread.java 工作线程 --TestThreadPool.java 程序入口 --ThreadPoolManager.java 线程池管理类
主要给大家介绍了关于java线程池使用后到底要不要关闭的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Reference: 《创建Java线程池》[1],《Java线程:新特征-线程池》[2], 《Java线程池学习》[3],《线程池ThreadPoolExecutor使用简介》[4],《Java5中的线程池实例讲解》[5],《ThreadPoolExecutor使用和思考》[6] ...
java 线程池 java 线程池 java 线程池 java 线程池
Java线程池使用说明Java线程池使用说明Java线程池使用说明
java线程池知识、
2.然后根据提示运行java命令执行示例程序,观看线程池的运行结果 目标:Java中多线程技术是一个难点,但是也是一个核心技术。因为Java本身就是一个多线程语言。本人目前在给46班讲授Swing的网络编程--使用Swing来...
java线程池封装j
java线程池实例java线程池实例E:\Users\Administrator\workspace
基于Java线程池技术实现Knock Knock游戏项目.zip 基于Java线程池技术实现Knock Knock游戏项目.zip 基于Java线程池技术实现Knock Knock游戏项目.zip 基于Java线程池技术实现Knock Knock游戏项目.zip 基于Java线程池...
讲述了java线程池的优点,参数,6种线程池的使用场景,线程池用到的handler,线程任务的提交方式等等。
自定义实现Java线程池,学习大师设计思想,瞻仰大神笔法
java技术学习——基于Java线程池技术实现Knock Knock游戏项目(包含服务端、客户端两部分) java技术学习——基于Java线程池技术实现Knock Knock游戏项目(包含服务端、客户端两部分) java技术学习——基于Java...
java线程池的源码分析以及各种池之间的对比;
JAVA线程池的原理与实现.pdf
JAVA使用线程池查询大批量数据
基于Java线程池技术的数据爬虫设计与实现.pdf
java 线程池jxl动态写入Excel
1.媲美java线程池框架,整套源码资源,使用Intellij Idea开发工具,JDK1.8以上 2.带有测试代码 3.可以根据项目实际情况任意调整代码 4.任务队列、拒绝策略 5.BasicThreadPool.java、LinkedRunnableQueue.java、...