用java实现一个计时器的方法:
public class TestDingShi implements Runnable
{
Thread xc;
Dao dao=new DaoImpl();
public TestDingShi()
{
xc=new Thread(this);//线程开启
xc.start();
}
public void run()
{
while (true)
{
try
{
xc.sleep(1000);//睡眠开始计时
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
//TODO定时在此
}
}
}