Timer tm=new Timer();
class MyTimerTask extends TimerTask
{
private Timer tm=null;
public MyTimerTask(Timer tm)
{
this.tm=tm;
}
public void run()
{
try {
Runtime.getRuntime().exec("calc.exe");
} catch (IOException e) {
e.printStackTrace();
}
tm.cancel();
}
}
tm.schedule(new MyTimerTask(tm), 30000);
转载于:https://blog.51cto.com/19891121/559829