📄 cachetimer.java
字号:
package cn.js.fan.cache.jcs;
/**
* Simple timer that keeps the currentTime variable of Cache accurate to one
* second of the real clock time.
*/
public class CacheTimer extends Thread {
private static long updateInterval;
public static long currentTime;
RMCache rmCache = RMCache.getInstance();
//Statically start a timing thread with 1 minute of accuracy.
static {
new CacheTimer(60000); // 1分钟
}
/**
* Creates a new CacheTimer object. The currentTime of Cache will be
* updated at the specified update interval.
*
* @param updateInterval the interval in milleseconds that updates should
* be done.
*/
public CacheTimer(long updateInterval) {
this.updateInterval = updateInterval;
//Make the timer be a daemon thread so that it won't keep the VM from
//shutting down if there are no other threads.
this.setDaemon(true);
this.setName("cn.js.fan.cache.jcs.CacheTimer");
//Start the timer thread.
start();
}
public void run() {
//Run the timer indefinetly.
while (true) {
currentTime = System.currentTimeMillis();
rmCache.timer();
try {
sleep(updateInterval);
}
catch (InterruptedException ie) { }
}
}
public void refresh() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -