使用Java Timer,然后切换到ScheduledExecutorService,但我的问题没有修复.在系统时间更改之前安排的任务(通过ntpd)不会在指定的延迟时执行.没有任何日志记录:(.
在64位linux上使用我的目标中的jre 1.6.0_26 64位.
更新: ScheduledExecutorService在Windows上运行正常.问题仅出在运行64位JVM的基于64位Linux的系统上.它在运行32位JVM的64位linux上运行良好......很奇怪.在任何博客上都没有找到任何相同的参考.
IBM的JAVA SDK也存在同样的问题(ibm-java-sdk-7.0-0.0-x86_64-archive.bin).
我已经提交了针对JDK 7139684的缺陷,它被接受但已被关闭并标记为 6900441的副本.请投票给它,如果你觉得它的价值得到修复...我不知道为什么它已经修复了几年以上
以下是我用来测试此问题的示例代码:
package test;
import java.io.IOException;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @author yogesh
*
*/
public class TimerCheck implements Runnable {
ScheduledExecutorService worker;
public TimerCheck(ScheduledExecutorService worker) {
super();
this.worker = worker;
this.worker.schedule(this, 1, TimeUnit.SECONDS);
}
private static void update() {
System.out.println("TimerCheck.update() "+new Date(System.currentTimeMillis()));
}
@Override
public void run() {
update();
worker.schedule(this, 1, TimeUnit.SECONDS);
}
/**
* @param args
*/
public static void …Run Code Online (Sandbox Code Playgroud)