B
bugbear
Long ago I carefully implemented a Shell out
command, following the guidance from this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Summary: use threads to gather stdout and stderr from
your exec, otherwise it might deadlock.
I even added (yet another) thread to implement timeouts
(to kill a shell script gone infinite).
Time moves on, and I now, under Tomcat, have a secondary
problem.
My threads are thrashing.
I'm using 4 threads (main, stdout_gather, stderr_gather, timeout)
per shell, and it's just too many.
Does anybody have any advice, experience, or code
to reduce this number.
My (hazy) thoughts involve using non-blocking IO to pick
up multiple stdout/stderr streams in a single thread (but I can't get a
Selectable from a Stream) and using a
single thread with a "next timeout" model to
use a single timout thread for all shell outs.
All input gratefully received.
BugBear
command, following the guidance from this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Summary: use threads to gather stdout and stderr from
your exec, otherwise it might deadlock.
I even added (yet another) thread to implement timeouts
(to kill a shell script gone infinite).
Time moves on, and I now, under Tomcat, have a secondary
problem.
My threads are thrashing.
I'm using 4 threads (main, stdout_gather, stderr_gather, timeout)
per shell, and it's just too many.
Does anybody have any advice, experience, or code
to reduce this number.
My (hazy) thoughts involve using non-blocking IO to pick
up multiple stdout/stderr streams in a single thread (but I can't get a
Selectable from a Stream) and using a
single thread with a "next timeout" model to
use a single timout thread for all shell outs.
All input gratefully received.
BugBear