【发布时间】:2009-02-24 21:59:26
【问题描述】:
我目前在我们的 Windows 2003 Server Box 上使用 Quartz Scheduler 作为 Cron 的替代品。 我有两个需要在新 VM 中启动的特定作业,因此我使用 Java 5 中的 ProcessBuilder 对象来获取我的“Process”对象。 我遇到的问题是当我们的 Quartz Scheduler JVM 停止时,单独的 JVM 中的 2 个作业继续运行。
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 弄清楚如何做到这一点。
提前谢谢你
【问题讨论】:
标签: java multithreading process