Callables and Futures
来源:互联网 发布:外贸邮件搜索软件 编辑:程序博客网 时间:2024/05/16 11:26
public interface Callable<V>
{
V call() throws Exception;
}
public interface Future<V>
{
V get() throws . . .;
V get(long timeout, TimeUnit unit) throws . . .;
void cancel(boolean mayInterrupt);
boolean isCancelled();
boolean isDone();
}
无参数的get方法会一直blocked直到计算完成,有参数如果时间到了还没完成,则抛出TimeoutException。他们两个都会抛出 InterruptedException
cancel方法试图中止任务线程。如果线程还没有start()那么它永不会开始,如果已经开始并且cancel的参数为true,则会调用interrupt()方法来中止
Callable<Integer> myComputation = . . .;
FutureTask<Integer> task = new FutureTask<Integer>(myComputation);
Thread t = new Thread(task); // it's a Runnable
t.start();
. . .
Integer result = task.get(); // it's a Future
- Callables and Futures
- Callables and Futures
- CassandraSF2011: Progress and Futures
- tcp/ip学习笔记--第24 TCP futures and performance
- 【Futures】&【Laws】
- 组合 Futures
- Hadoop Futures at Structure Big Data: DataStax Brisk, EMC, and MapR
- 探索 ASP.NET Futures
- Dynamic programming futures
- FUTURES CRM 大战略
- HBase Futures @Hortonworks
- Non Standard Futures & Options
- Trademiner, Stocks, Futures & Forex!
- akka入门-Futures
- Concurrent.futures vs Multiprocessing
- concurrent.futures源码解析
- Futures Contract Symbols naming convention
- Futures/Promises Golang方式实现
- .net多文件上传的解决方法
- extlib 5.0 学习笔记 cache application block 4 设计与实现
- Sql 连接串
- Linux下安装配置 Jdk1.6+Tomcat6+Apache2.2.x+jk_mod1.2 详解
- sql中的minus,union/静态类及 Global
- Callables and Futures
- Linux下JDK1.6+JBOSS4.0配置安装
- netcdf入门
- Application.DoEvents()的作用
- STL中的内存分配方式——3
- Linux系统中OpenSSH的安装和配置
- 全文索引------新手入门(二)
- 要下载软件
- Twisted网络编程必备