From: Updike, C. <Cla...@jh...> - 2003-11-24 15:02:32
|
One piece of advice regarding that article--the author's code for the GoodWinRedirect class contains the following snippet: // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? int exitVal = proc.waitFor(); System.out.println("ExitValue: " + exitVal); I was having intermittent failures using this code until I joined the "gobbler" threads before exiting the method: // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? int exitVal = proc.waitFor(); System.out.println("ExitValue: " + exitVal); //ADD THIS: // make sure all the stream output has been processed before proceeding errorGobbler.join(); outputGobbler.join(); I'm guessing that in some cases the gobbler threads hadn't finished their processing before the method was exiting and the buffers were empty as a result. -Clark On Thu, 20 Nov 2003, mike wrote: <snip> and JavaWorld has written a very good article about its traps (and how to avoid them... *grin*): http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html |