WEB开发网
开发学院WEB开发Jsp 一个简单的定时器应用: VarTimer (java) 阅读

一个简单的定时器应用: VarTimer (java)

 2008-01-05 09:39:14 来源:WEB开发网   
核心提示:package cn.com.softwise.mailplug.service; import java.util.Timer; import java.util.TimerTask; public class VarTimer { PRivate Timer timer; private int

  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;
}
}

Tags:一个 简单 定时器

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接