How do I stop Ant from hanging after executing a java program that attempted to interrupt a thread (and failed) and continued?
- by Zugwalt
I have Ant build and execute a java program. This program tries to do something that sometimes hangs, so we execute it in a thread.
actionThread.start();
try {
actionThread.join(10000);
} catch (InterruptedException e) {
System.out.println("InterruptedException: "+e.getMessage());
}
if (actionThread.isAlive()) {
actionThread.interrupt();
System.out.println("Thread timed out and never died");
}
The ant call looks like this:
<java fork="true" failonerror="yes" classname="myPackage.myPathName" classpath="build">
<arg line=""/>
<classpath>
<pathelement location="bin" />
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</java>
And when this runs I see the "Thread timed out and never died" statement, and I also see the main program finish execution, but then Ant just hangs. Presumably it is waiting for the child threads to finish, but they never will.
How can I have Ant be done once it is done executing main() and just kill or ignore dead threads?