日期:2014-05-20 浏览次数:20810 次
import java.util.Timer;
import java.util.TimerTask;
class Test
{
public static void main(String[] args)
{
Timer timer = new Timer();
timer.schedule(new Test1(),1000, 1000);
}
}
class Test1 extends TimerTask
{
int count = 5;
@Override
public void run()
{
if(count > 0)
{
System.out.println("hello world");
count--;
}
else
{
this.cancel();
System.exit(0);
}
}
}