java:删除实现 IScheduledJob 的类中的当前计划作业
在执行计划作业本身时,我想阻止它一次又一次地执行,如果没有我首先创建作业时收到的字符串,我该如何做到这一点?
public class UfkJob implements IScheduledJob {
public void execute(ISchedulingService service) {
if (...) {
/* here i want to remove the current running job */
}
}
我使用以下命令在外部执行该作业:
ISchedulingService service = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
service.addScheduledJobAfterDelay(5000,new UfkJob(),200);
In the execution of the scheduled job itself i want to stop it from being executed again and again, how can i do so without having the string that i received when i created the job in the first place ?
public class UfkJob implements IScheduledJob {
public void execute(ISchedulingService service) {
if (...) {
/* here i want to remove the current running job */
}
}
I executed the job outside by using the commands:
ISchedulingService service = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
service.addScheduledJobAfterDelay(5000,new UfkJob(),200);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚意识到我认为我最初回答了错误的问题,为了后代,我将把它留在下面。再次假设我正在寻找正确的 API。添加一个字段到 UFkJob:
然后当你安排工作时:
或者你总是可以拥有工作安排本身:
----- 下面是我原来的答案,我相信是错误的问题 ----
我不确定是否我正在查看正确库的 API 文档,但是您的方法调用:
定义为:
关键是“定期执行”。听起来您正在寻找的是:
因此,您的调用将是:
它将在方法调用后 5 秒执行一次 UfkJob。
I just realized I think I answered the wrong question initially, I will leave it below for the sake of posterity. Again an assumption I am looking at the right API. Add a field to UFkJob:
and then when you schedule the job:
or you could always have the job schedule itself:
----- My original answer below, I believe for the wrong question ----
I'm not sure if I am looking at the API docs for the right library, however your method call:
is defined as:
The key being "periodic execution". It sounds like what you are looking for is:
So your call would be:
Which would execute the UfkJob a single time 5 seconds after the method call.