Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@jakarta.apache.org Received: (qmail 54008 invoked by uid 500); 17 Apr 2001 19:53:25 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: ant-user@jakarta.apache.org Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 53985 invoked from network); 17 Apr 2001 19:53:21 -0000 Message-ID: <530FCFB08F31D411A47F009027D5D01F01127C42@conan.esr.hp.com> From: "Halim, Salman" To: "'ant-user@jakarta.apache.org'" , "'ant-dev@jakarta.apache.org'" Subject: exec in thread Date: Tue, 17 Apr 2001 15:56:15 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C0C778.76073280" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C0C778.76073280 Content-Type: text/plain; charset="iso-8859-1" hi, i have the attached MyExec class; this is supposed to be a primitive replacement for the exec task that will run its target in the background (by spawning a thread and running in there). it isn't complete yet, but i wanted to do some testing before going any further: in short, the thread doesn't continue to run once the main class is done. if i uncomment the delay loop in there, then it runs (because the main MyExec is still running). can anybody see if i'm doing something anti-ant in there, please? this class is not very complicated, i promise! thank you in advance, -- Salman Halim Advisory Software Engineer, HP Bluestone Quidquid latine dictum sit, altum viditur. ------_=_NextPart_000_01C0C778.76073280 Content-Type: application/octet-stream; name="MyExec.java" Content-Disposition: attachment; filename="MyExec.java" // -*- java -*- // FILE: "C:\tmp\org\apache\tools\ant\MyExec.java" {{{ // LAST MODIFICATION: "Tue, 17 Apr 2001 15:47:27 Eastern Daylight Time ()" // (C) 2001 by Salman Halim, // $Id:$ }}} package org.apache.tools.ant; import java.io.File; import org.apache.tools.ant.types.Environment; import org.apache.tools.ant.types.Commandline; public class MyExec extends Task { protected String executable; protected File dir; protected Environment env = new Environment (); protected Commandline cmdl = new Commandline (); public void setExecutable (String val) { executable = val; System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec setExecutable executable: " + executable); // remove } public void setDir (File val) { dir = val; System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec setDir dir: " + dir); // remove } public void addEnv (Environment.Variable var) { env.addVariable (var); System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec addEnv var: " + var); // remove } public Commandline.Argument createArg () { System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec createArg: "); // remove return cmdl.createArgument (); } public void execute () throws BuildException { System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec execute env: " + env); // remove System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec execute cmdl: " + cmdl); // remove BGRunner runner = new BGRunner (); Thread t = new Thread (runner); runner.setExec (this); t.start (); System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec execute it's running!: "); // remove /* try { Thread.sleep (10000); } catch (Exception e) { } */ } } class BGRunner extends Thread { protected MyExec exec; protected boolean running = false; public BGRunner () { } public void run () { if (running) return; running = true; System.out.println ("-=-=-=-=-=-=-=-=-=-= MyExec BGRunner: "); // remove int i = 0; while (i < 1000) System.out.println (i++); // remove } public void setExec (MyExec e) { exec = e; } } ------_=_NextPart_000_01C0C778.76073280--