一个简单的定时器应用: VarTimer (java)
类别: JAVA教程
package cn.com.softwise.mailplug.service;
import java.util.Timer;
import java.util.TimerTask;
public class VarTimer {
private Timer timer;
private int iFreq;
private boolean bRuning;
public VarTimer() {
timer = null;
bRuning = false;
iFreq = 10;
}
public void start(){
if(!bRuning){
timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
bRuning = false;
timer.cancel();
}
} , iFreq * 60 * 1000);
bRuning = true;
}
}
public boolean getCanSendDo(){
return !bRuning;
}
}
import java.util.Timer;
import java.util.TimerTask;
public class VarTimer {
private Timer timer;
private int iFreq;
private boolean bRuning;
public VarTimer() {
timer = null;
bRuning = false;
iFreq = 10;
}
public void start(){
if(!bRuning){
timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
bRuning = false;
timer.cancel();
}
} , iFreq * 60 * 1000);
bRuning = true;
}
}
public boolean getCanSendDo(){
return !bRuning;
}
}
- 上一篇: 用Java编写扫雷游戏--代码思想
- 下一篇: java.util.Collection
-= 资 源 教 程 =-
文 章 搜 索