2.Future

作者: 元代码 | 来源:发表于2017-09-22 11:27 被阅读0次

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.
在指定的等待时间内让任务执行(如需要等待),如果有结果就返回

相关文章

  • 2.Future

    Future接口,顾名思义标的一个任务的未来:要么执行完成要么被取消方法说明:1.boolean cancel(b...

  • 2018-12-21

    1. 错误一定要打日志! 异常错误与日志的记录,需要同步 2.Future 一定要处理异常 当异步调用内,抛出ru...

  • v衣服u才吃饭v换个v根本就见或不见

    句v好v哈哈哈vv好v好百度v菊花会v好vv结婚v好vv好v好v好v好v好v好给v很尴尬v好v给v给v呵呵v好v呼...

  • Vue基础备忘

    常用 v-if,v-show,v-for,v-bind,v-on,v-text,v-html,v-cloak,v-...

  • 指令

    v-once v-html v-bind v-if v-show v-text v-pre v-cloak v-o...

  • Vue指令汇集

    v-html v-bind v-once v-on v-if v-show v-if vs v-showv-if ...

  • 指令

    指令 v-text v-html v-show v-if v-else v-else-if v-for v-on ...

  • vue基础

    基础 指令 v-text v-html v-for v-if v-else v-show v-cloak v-on...

  • 面经之vue

    基本指令 v-for v-on v-bind v-text v-if v-else-if v-else v-sho...

  • 12.12 默写

    1.指令 v-text v-show v-if v-else v-for v-on v-bind v-model ...

网友评论

      本文标题:2.Future

      本文链接:https://www.haomeiwen.com/subject/cagxextx.html