2 回答

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個(gè)贊
很有意思的問題,試了很多方法都沒達(dá)到要求。
現(xiàn)在能想到的最好方法是
Thread hook = new Thread() {
public void run() {
try {
Runtime.getRuntime().exec("cmd /C D:/1.exe");
} catch (IOException e) {
e.printStackTrace();
}
}
};
Runtime.getRuntime().addShutdownHook(hook);
Thread shutdown=new Thread(){
Object waiter=new Object();
public void run(){
synchronized(waiter){
try {
waiter.wait(1000);
} catch (InterruptedException e) {
}
}
Runtime.getRuntime().halt(0);
}
};
Runtime.getRuntime().addShutdownHook(shutdown);
System.exit(0);
添加回答
舉報(bào)