如何获取预定作业列表并在 Play Framework 中将其停止?

How to get the list of scheduled job and stop it in Play Framework?

我正在使用 ActorSystem.scheduler.schedule() 方法,它可以很好地工作 问题是:当我想停止预定的工作时,如何找到并停止它? 我查看了文档,找不到解决方法。

Scheduling a task will result in a Cancellable (or throw an IllegalStateException if attempted after the scheduler’s shutdown). This allows you to cancel something that has been scheduled for execution.

基本上,调用 schedule() 将 return 一个可取消的任务。您所要做的就是维护它并在某个时候调用 cancel()More details here.