cachetimer.java
来自「云网论坛CWBBS 源码,内容丰富,学习,参考,教学的好资料,具体见内说明,」· Java 代码 · 共 53 行
JAVA
53 行
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 + =
减小字号Ctrl + -
显示快捷键?