How do I stop Ant from hanging after executing a java program that attempted to interrupt a thread (and failed) and continued?
Posted
by
Zugwalt
on Stack Overflow
See other posts from Stack Overflow
or by Zugwalt
Published on 2010-12-30T17:06:38Z
Indexed on
2010/12/31
3:53 UTC
Read the original article
Hit count: 211
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?
© Stack Overflow or respective owner