b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

scheduledthreadpoolexecutor?java线程池?fileoutputstream 追加?API之

电脑杂谈  发布时间:2016-09-25 17:02:00  来源:网络整理

你是否正在寻找关于scheduledthreadpoolexecutor的内容?让我把最俱价值的东西奉献给你:

java.util.concurrent
scheduledthreadpoolexecutor

java.lang.Object

继承者

java.util.concurrent.AbstractExecutorService

继承者

java.util.concurrent.ThreadPoolExecutor

继承者

java.util.concurrent.scheduledthreadpoolexecutor 所有已实现的接口: Executor, ExecutorService, ScheduledExecutorService public class scheduledthreadpoolexecutorextends ThreadPoolExecutor
implements ScheduledExecutorService

ThreadPoolExecutor,它可另行安排在给定的延迟后运行命令,或者定期执行命令。需要多个辅助线程时,或者要求 ThreadPoolExecutor 具有额外的灵活性或功能时,此类要优于 Timer。

一旦启用已延迟的任务就执行它,但是有关何时启用,启用后何时执行则没有任何实时保证。按照提交的先进先出 (FIFO) 顺序来启用那些被安排在同一执行时间的任务。

虽然此类继承自 ThreadPoolExecutor,但是几个继承的调整方法对此类并无作用。特别是,因为它作为一个使用 corePoolSize 线程和一个无界队列的固定大小的池,所以调整 maximumPoolSize 没有什么效果。

扩展注意事项:此类重写 AbstractExecutorService 的 submit 方法,以生成内部对象控制每个任务的延迟和调度。若要保留功能性,子类中任何进一步重写的这些方法都必须调用超类版本,超类版本有效地禁用附加任务的定制。但是,此类提供替代受保护的扩展方法 decorateTask(为 Runnable 和 Callable 各提供一种版本),可定制用于通过 execute、submit、schedule、scheduleAtFixedRate 和 scheduleWithFixedDelay 进入的执行命令的具体任务类型。默认情况下,ScheduledThreadPoolExecutor 使用一个扩展 FutureTask 的任务类型。但是,可以使用下列形式的子类修改或替换该类型。 public class CustomScheduledExecutor extends scheduledthreadpoolexecutor { static class CustomTask<V> implements RunnableScheduledFuture<V> { ... } protected <V> RunnableScheduledFuture<V> decorateTask( Runnable r, RunnableScheduledFuture<V> task) { return new CustomTask<V>(r, task); } protected <V> RunnableScheduledFuture<V> decorateTask( Callable<V> c, RunnableScheduledFuture<V> task) { return new CustomTask<V>(c, task); } // ... add constructors, etc. }

从以下版本开始: 1.5

嵌套类摘要

从类 java.util.concurrent.ThreadPoolExecutor 继承的嵌套类/接口

ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy

构造方法摘要

scheduledthreadpoolexecutor(intcorePoolSize)
使用给定核心池大小创建一个新 scheduledthreadpoolexecutor

scheduledthreadpoolexecutor(intcorePoolSize, RejectedExecutionHandlerhandler)
使用给定初始参数创建一个新 scheduledthreadpoolexecutor

scheduledthreadpoolexecutor(intcorePoolSize, ThreadFactorythreadFactory)
使用给定的初始参数创建一个新 scheduledthreadpoolexecutor

scheduledthreadpoolexecutor(intcorePoolSize, ThreadFactorythreadFactory, RejectedExecutionHandlerhandler)
使用给定初始参数创建一个新 scheduledthreadpoolexecutor

方法摘要

protected

<V> RunnableScheduledFuture<V>

decorateTask(Callable<V>callable, RunnableScheduledFuture<V>task)
修改或替换用于执行 callable 的任务。

protected

<V> RunnableScheduledFuture<V>

decorateTask(Runnablerunnable, RunnableScheduledFuture<V>task)
修改或替换用于执行 runnable 的任务。

void execute(Runnablecommand)
使用所要求的零延迟执行命令。

boolean getContinueExistingPeriodicTasksAfterShutdownPolicy()
获取有关在此执行程序已 shutdown 的情况下、是否继续执行现有定期任务的策略。

boolean getExecuteExistingDelayedTasksAfterShutdownPolicy()
获取有关在此执行程序已 shutdown 的情况下是否继续执行现有延迟任务的策略。

BlockingQueue<Runnable> getQueue()
返回此执行程序使用的任务队列。

boolean remove(Runnabletask)
从执行程序的内部队列中移除此任务(如果存在),从而如果尚未开始,则其不再运行。

<V> ScheduledFuture<V>

schedule(Callable<V>callable, longdelay, TimeUnitunit)
创建并执行在给定延迟后启用的 ScheduledFuture。

ScheduledFuture<?> schedule(Runnablecommand, longdelay, TimeUnitunit)
创建并执行在给定延迟后启用的一次性操作。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-17399-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...