我目前在我們的Windows 2003 Server Box上使用Quartz Scheduler作爲Cron的替代品。 我有兩個特定的作業需要在新的VM中啓動,所以我使用Java 5中的ProcessBuilder對象來獲取我的「Process」對象。 我遇到的問題是當我們的Quartz Scheduler JVM停止時,單獨JVM中的2個作業繼續運行。如果Quartz Scheduler死亡,我該如何阻止它啓動的子進程?
Process process = Runtime.getRuntime().exec(command);
try
{
while (true)
{
Thread thread1 = new Thread(new ReaderThread(process.getInputStream()));
Thread thread2 = new Thread(new ReaderThread(process.getErrorStream()));
thread1.start();
thread2.start();
thread1.join();
thread2.join();
當我的Quartz Scheduler關聯的父JVM死亡時,有沒有辦法殺死這些線程?即使我知道一種方法可以通過手動方式從不同的進程中殺死它們,我也可以通過Quartz瞭解如何實現。
預先感謝您