Java Cron4J 持久任务
目前,我正在运行一个夜间服务器任务,该任务是使用 Cron4J 在 Java 中开发的。现在我选择了 Cron4J 而不是标准的 Java.util.Timer,因为它即使在服务器崩溃或关闭后也能持久运行任务。
然而我似乎无法完全关闭任务。我可以设法在它运行时停止它,但是当服务器重新启动时它会立即启动。
有人有使用 Cron4J 库的经验吗?如果可能的话,我希望能够杀死所有睡眠任务。
开发平台:Windows 7、Apache Tomcat 7、JDK 6。
感谢您的帮助或建议。
Currently i'm running a nightly server task which was developed in Java using Cron4J. Now i chose Cron4J over the standard Java.util.Timer because of its persistence running the task even after the server has crashed or shut down.
However i cannot seem to shut the task off completely. I can manage to stop it while it is running, however it starts right back up when the server gets restarted.
Has anyone had any experience using the Cron4J library? I would like to be able to kill all sleeping tasks if it is possible.
Developing on: Windows 7, Apache Tomcat 7, JDK 6.
Thanks for any help or advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已调用 deschedule 并且没有从队列中删除任务?您必须为所有睡眠任务调用它,没有办法说取消每一个睡眠任务。如果将所有任务放在一个文件中,您可以 descheduleFile,这可能会更高效。
Have you called deschedule and that didn't remove the task from the queue? You will have to call it for ALL sleeping tasks, there is no way to say cancel every single sleeping task. If you put all your tasks in a file you can descheduleFile, which may be more efficient.