Callable和Future实现多线程Future取得的结构类型和Callable返回的结果类型必须一致。Callable要采用ExecutorService的submit方法提交,返回的future对象可以取消任务1.提交任务,得到任务的返回结果举例ExecutorServicethreadPool=Executors.newSingleThreadExecutor();Future..
分类:
编程语言 时间:
2016-07-06 18:42:22
阅读次数:
177
package csdn; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * @author nineday */ public class Test { public ...
分类:
编程语言 时间:
2016-07-05 22:30:37
阅读次数:
181
上一篇学习了ExecutorService和其它相关类的源码,本篇要学习的BlockingQueue中的源码,as always,先上类图 其实继承(实现)的层次比较简单,我们只要需要先学习一下BlockingQueue中的方法: 其实除了poll和offer 其它方法一般我们是用不到的,所以还是很 ...
分类:
其他好文 时间:
2016-07-04 15:32:36
阅读次数:
120
Executors private ExecutorService proThreadPool = Executors.newFixedThreadPool(50); ...
分类:
编程语言 时间:
2016-07-02 20:12:09
阅读次数:
1132
一:newCachedThreadPool (1)缓存型池子,先查看池中有没有以前建立的线程,如果有,就reuse,如果没有,就建立一个新的线程加入池中; (2)缓存型池子,通常用于执行一些生存周期很短的异步型任务;因此一些面向连接的daemon型server中用得不多; (3)能reuse的线程, ...
分类:
编程语言 时间:
2016-07-02 20:07:55
阅读次数:
148
java.util.concurrent.Executors Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory, and Callable classe ...
分类:
其他好文 时间:
2016-07-02 18:49:28
阅读次数:
158
void java.util.concurrent.Executor.execute(Runnable command) execute void execute(Runnable command) Executes the given command at some time in the fut ...
分类:
其他好文 时间:
2016-07-02 17:22:46
阅读次数:
154
java.util.concurrent.ExecutorService An Executor that provides methods to manage termination and methods that can produce a Future for tracking progre ...
分类:
其他好文 时间:
2016-07-02 17:21:24
阅读次数:
261
JAVA多线程实现方式主要有三种:继承Thread类、实现Runnable接口、使用ExecutorService、Callable、Future实现有返回结果的多线程。其中前两种方式线程执行完后都没有返回值,只有最后一种是带返回值的。 thread和runnable不讨论了。 太多地方可以找到他们 ...
分类:
编程语言 时间:
2016-06-30 18:29:04
阅读次数:
203
Executor框架 Executor ExecutorService AbstractExecutorService ThreadPoolExecutor ThreadPoolExecutor继承AbstractExecutorService,是一个线程池的具体的实现 主要成员 1. ctl At ...
分类:
编程语言 时间:
2016-06-25 16:20:10
阅读次数:
171