time.schedule(new TimerTask(){
public void run()
{
System.out.println("haha haha");
JOptionPane.showMessageDialog(f,"error","worning",JOptionPane.WARNING_MESSAGE);
}
},date);
任务是执行了,但是如何就让他执行一次呢??
time.cancel();怎么写才合适呢??
public void run()
{
System.out.println("haha haha");
JOptionPane.showMessageDialog(f,"error","worning",JOptionPane.WARNING_MESSAGE);
}
},date);
任务是执行了,但是如何就让他执行一次呢??
time.cancel();怎么写才合适呢??
你调用的是
schedule(TimerTask task, Date time)
Schedules the specified task for execution at the specified time.根据API任务会在你指定的时间被执行一次。
跟个参数就行了!