ScheduledFuture<wbr style="line-height:25px"><br style="line-height:25px">
java.util.concurrent<br style="line-height:25px">
接口ScheduledFuture<V><br style="line-height:25px">
类型参数:<br style="line-height:25px">
V-此Future返回的结果类型。<br style="line-height:25px">
所有超级接口:<br style="line-height:25px">
Comparable<Delayed>,Delayed,Future<V><br style="line-height:25px">
所有已知子接口:<br style="line-height:25px"><span style="color:#0000ff; line-height:25px">RunnableScheduledFuture<V></span><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">ScheduledFuture</span>很简单,它就是在Future<V>基础上还<wbr style="line-height:25px"><span style="color:#000080; line-height:25px">集成了</span><span style="color:#ff6600; line-height:25px">Comparable<Delayed></span><span style="color:#000080; line-height:25px">和</span><span style="color:#ff6600; line-height:25px">Delayed</span><span style="color:#000080; line-height:25px">的接口<wbr style="line-height:25px">。</wbr></span><br style="line-height:25px">
它用于表示<wbr style="line-height:25px"><span style="color:#99cc00; line-height:25px">ScheduledExecutorService</span><wbr style="line-height:25px">中提交了任务的返回结果。我们通过<span style="color:#ff6600; line-height:22px">Delayed</span><span style="color:#000080; line-height:22px">的接口</span><span style="color:#993300; line-height:25px">getDelay()</span>方法知道该任务还有好久才被执行。
<div style="line-height:25px">
<div style="line-height:25px">关于<span style="line-height:25px; color:rgb(153,204,0)">ScheduledExecutorService</span>的更多内容请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920109643632988/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">ScheduledThreadPoolExecutor</a></strong>》</div>
<div style="line-height:25px"><span style="line-height:25px">主要函数</span></div>
<div style="line-height:25px">
<span style="color:#993300; line-height:25px">long</span><span style="color:#ff6600; line-height:25px">getDelay</span>(TimeUnitunit)<br style="line-height:25px">
返回与此对象相关的剩余延迟时间,以给定的时间单位表示。<br style="line-height:25px">
参数:<br style="line-height:25px">
unit-时间单位<br style="line-height:25px">
返回:<br style="line-height:25px"><span style="color:#000080; line-height:25px">剩余延迟时间;零或负值指示延迟时间已经用尽</span><br style="line-height:25px"><span style="line-height:25px"><wbr style="line-height:25px">注意1</wbr></span><wbr style="line-height:25px">:JDK中并没提供ScheduledFuture的实现类。只有在ScheduledExecutorService中提交了任务,<br style="line-height:25px">
才能返回一个实现了<span style="color:#99cc00; line-height:25px">ScheduledFuture</span>接口的对象。<br style="line-height:25px"><wbr style="line-height:25px"><span style="color:#ff00ff; line-height:25px">RunnableScheduledFuture</span><wbr style="line-height:25px"><br style="line-height:25px">
java.util.concurrent<br style="line-height:25px">
接口RunnableScheduledFuture<V><br style="line-height:25px">
类型参数:<br style="line-height:25px">
V-此Future的get方法所返回的结果类型。<br style="line-height:25px">
所有超级接口:<br style="line-height:25px">
Comparable<Delayed>,Delayed,Future<V>,Runnable,RunnableFuture<V>,ScheduledFuture<V><br style="line-height:25px"><span style="color:#993300; line-height:25px">publicinterface</span><span style="color:#ff00ff; line-height:25px">RunnableScheduledFuture</span><V><br style="line-height:25px">
extendsRunnableFuture<V>,ScheduledFuture<V><br style="line-height:25px"><span style="line-height:25px; color:rgb(255,0,255)">RunnableScheduledFuture</span>作为 是实现了Runnable的ScheduledFuture。当成功执行<span style="line-height:25px; color:rgb(255,0,255)">RunnableScheduledFuture</span>对象的run方法后,可以通过该<span style="line-height:25px; color:rgb(255,0,255)">RunnableScheduledFuture</span>对象的Future
接口并允许访问其结果。</wbr></wbr></wbr>
</div>
<div style="line-height:25px">
<span style="color:#ff00ff; line-height:25px">RunnableScheduledFuture</span>做为ScheduledFuture的子类,它集成了<span style="color:#99cc00; line-height:25px">RunnableFuture<V></span>和<span style="color:#808000; line-height:25px">ScheduledFuture<V></span>这两个接口。<br style="line-height:25px">
</div>
<div style="line-height:25px">
<span style="line-height:25px">唯一自定义接口</span><br style="line-height:25px"><span style="color:#993300; line-height:25px">boolean</span><wbr style="line-height:25px"><span style="color:#ff6600; line-height:25px">isPeriodic()</span><wbr style="line-height:25px"><br style="line-height:25px">
如果这是一个定期任务,则返回true。定期任务可以根据计划重新运行。非定期任务只能运行一次。<br style="line-height:25px">
返回:<br style="line-height:25px">
如果此任务是定期的,则返回true</wbr></wbr>
</div>
</div>
</wbr></wbr></wbr></wbr>
ScheduledFuture和RunnableScheduledFuture
最新推荐文章于 2024-11-01 14:21:07 发布