2.Future<V>

Future接口,顾名思义标的一个任务的未来:要么执行完成要么被取消
方法说明:
1.boolean cancel(boolean mayInterruptIfRunning);
Attempts to cancel execution of this task. This attempt will
fail if the task has already completed, has already been cancelled,
or could not be cancelled for some other reason
取消执行任务。如果任务已经执行完成,或者已经取消,或者由于其他原因不能被取消,则取消失败
通过参数设置是否打断任务的执行
2.boolean isCancelled();
if this task was cancelled before it completed normally
查看正常结束之前是否被取消
3.boolean isDone();
if this task completed
查看任务是否已结束
4.V get() throws InterruptedException, ExecutionException;
Waits if necessary for the computation to complete, and then
retrieves its result
等到任务执行结束(如需要等待),然后返回结果
5.V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result, if available.
在指定的等待时间内让任务执行(如需要等待),如果有结果就返回

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 5.SDWebImageDownloader 下面分析这个类看这个类的结构 这个类的属性比较多。 先看这个类的pu...
    充满活力的早晨阅读 1,134评论 0 0
  • Android Handler机制系列文章整体内容如下: Android Handler机制1之ThreadAnd...
    隔壁老李头阅读 4,333评论 2 12
  • 1、一般来说,我们常见的使用图片的优化方案有base64编码、雪碧图、字体图片、图片压缩等 base64编码(1 ...
    Axiba阅读 2,744评论 0 0
  • 听说你们那里很冷 可我这里却冬阳暖照 此刻我拿一条板凳儿 坐于后园大树下 直视太阳的光辉 阳光轻抚着我的面庞 可我...
    暮罹阅读 159评论 0 0
  • 看百度百科 中文名 主营业务 对象 经营目标而从事的日常活动 接下来要做的是把课文上的逻辑整理出来,做出思维导...
    aabebw阅读 199评论 0 0