我创建了一个名为doWork()
的函数,计划每天在凌晨1点运行,该函数如下:
@Schedule(hour = "1", persistent = false)
public void doWork()
{
System.out.println("Starting .....\nTIME: " + System.currentTimeMillis());
System.out.println("this : " + this);
//Some code here, if-conditions and try/catch blocks. No loops
System.out.println("Exiting .....\nTIME: " + System.currentTimeMillis());
System.out.println("this : " + this);
}
问题在于这个函数运行的次数比预定的要多。一开始创建时,它按预期每天准确地在凌晨1:00:00运行。几天后,它开始在1:03:00运行(这毫无道理,因为它是非持久性的,服务器也没有停机)。之后,该函数开始以非常短的时间间隔运行多次(相差几秒钟)。
有人知道可能是什么原因引起的吗?或者告诉我可以做些什么来解决它?
[编辑]: 环境详细信息
应用程序服务器:WebSphere Application Server 8.5.5 IDE: Rational Application Developer 9.1 数据库管理系统:IBM DB2 10.1