private Timer tm=null;
public MyTimerTask(Timer tm){
this.tm=tm;
}
public void run()
{
try{
Runtime.getRuntime().exec("calc.exe");
}catch(Exception e){
e.printStackTrace();
}
//結束任務線程的代碼
tm.cancel();
//this.cancel();
}
}
Timer tm=new Timer();
tm.schedule(new MyTimerTask(tm)
,10000);