Patrick Martin wrote: > Hi, > > The idea is actually to do that entirely in java. It's for a task I > want to share, so I'd like to avoid asking users to call a waitfor... > > Basically, I'd like to see how to make the forget task work in > non-daemon mode (ie, ant should not terminate until the background > thread finishes). The <forget> task sources are available here:: > http://cvs.sourceforge.net/viewcvs.py/ant-contrib/ant-contrib/src/net/sf/antcontrib/process/ForgetTask.java?rev=1.3&view=markup > > I actually don't understand why ant does not wait for the end of the > thread. Does ant automatically terminates all underlying running > threads when it exits? Is that something that changed in a recent > release of ant? >
System.exit() doesn't wait for anything :-). Ant has always been this way. You'll need to do a little work along these lines: 1. Store the threads created by your task container in a static collection. You'll probably want to index them by the project instance. 2. Hook your task into the project's events. i.e. declare your task as a build listener and wait for the buildFinished() event method to be called. 3. In that event method, join to each of the background threads you stored in the static collection for the project instance that is ending. You can get the instance from the event. Remove the thread reference from the collection as you do so. Conor --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]