用java实现一个计时器的方法:
publicclassTestDingShiimplementsRunnable
{
Threadxc;
Daodao=newDaoImpl();
publicTestDingShi()
{
xc=newThread(this);//线程开启
xc.start();
}
publicvoidrun()
{
while(true)
{
try
{
xc.sleep(1000);//睡眠开始计时
}
catch(InterruptedExceptione)
{
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
//TODO定时在此
}
}
}