从 suspension/hibernation 恢复计算机后如何告诉 ScheduledExecutorService 忽略重叠执行

How to tell ScheduledExecutorService to ignore overlapping executions after resuming computer from suspension/hibernation

我有一个线程负责每 10-15 分钟定期刷新一些远程服务查询响应缓存。

问题是当客户端的机器从睡眠中恢复时,刷新任务执行睡眠时间/刷新周期时间而不是只执行一次。

它不会使服务器或任何东西超载,但效率低下。我怎样才能防止这种情况发生?

假设通过 ScheduledExecutorService, change the task to a self-scheduling task 以固定速率安排任务。 以这种方式,总是只有 1 个任务等待执行。