【问题标题】:Singlethreaded ScheduledThreadPoolExecutor with calls limit具有调用限制的单线程 ScheduledThreadPoolExecutor
【发布时间】:2013-03-25 11:27:14
【问题描述】:

我想利用 java.util.concurrent.Executors 来触发一些跑步者。 问题是我想按固定次数发射它。将这些跑步者称为固定费率很重要。

对我来说,使用 Executors#newSingleThreadScheduledExecutor 就足够了,所以我想知道为什么这是不可能的......

谢谢

【问题讨论】:

    标签: concurrency timertask scheduledexecutorservice


    【解决方案1】:

    我试图用 TimerTask 来解决这个问题,但效果相同。 问题是如何有效、优雅和安全地 - 在一定数量的调用后关闭 TimerTask、ScheduledExecutorService ...

    【讨论】:

    • 我找到了一些解决方案 + 但我想它对于 Executors#newSingleThreadScheduledExecutor 来说有机会相当稳定。我只是根据条件直接在我的 Runnable/Callable 中取消 ScheduledFuture。 ScheduledFuture 作为 executorService.scheduleAtFixedRate(myRunnable,....)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 2010-12-14
    • 1970-01-01
    • 2012-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多