<div>Thanks Glynn Clements:</div>
<div>I noticed that you have mentioned Grass library more than one times?</div>
<div>I think I did not use them?</div>
<div>I just have three java class the handle the grass commond,and the real call of grass is through the Runtime.exec() method ,it do open a new process.<br><br></div>
<div class="gmail_quote">2009/9/21 Glynn Clements <span dir="ltr">&lt;<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>&gt;</span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im"><br>maven apache wrote:<br><br>&gt; I am not exactly sure your meaning.<br>&gt; What is short-lived process and what is persisitent process&gt;?<br><br></div>By &quot;short-lived non-interactive command&quot;, I&#39;m talking about a typical<br>
GRASS command: it reads parameters from the command line, performs<br>some processing, then exits. If there are any errors, then it just<br>exits, often without performing any significant processing.<br><br>By &quot;persistent process&quot; I&#39;m talking about something like a daemon or a<br>
GUI application, which performs multiple operations, and keeps<br>performing operations until it is specifically instructed to<br>terminate.<br>
<div class="im"><br>&gt; Did you mean that if a process takes long time,then a error can terminate<br>&gt; this thread?<br><br></div>It doesn&#39;t matter how long it takes; any error will normally terminate<br>the process. For a simple command, this isn&#39;t a problem; if the<br>
library function didn&#39;t terminate the process, the main program would<br>terminate itself once the error was reported.<br><br>But for a persistent process which performs multiple operations, an<br>error would normally result in it aborting the current operation then<br>
proceding to the next operation. This isn&#39;t possible if you&#39;re using<br>the GRASS libraries, as they don&#39;t generally permit the process to<br>continue after an error has occurred.<br>
<div class="im"><br>&gt; and the web server is in the same thread,so it is shut down?<br>&gt; If so ,does it mean that I should open a new thread for each grass commond?<br><br></div>This is about processes, not threads.<br>
<br>AFAIK, Tomcat behaves as a server, receiving requests from Apache and<br>passing them to Java modules for processing. If you use Tomcat to run<br>a module which uses GRASS library functions, if the GRASS library<br>function signals an error, it will call exit() which will terminate<br>
the current process, i.e. it will terminate Tomcat.<br><br>If you want to avoid this, you need to process each request in a<br>separate *process*; a separate thread doesn&#39;t help, as exit()<br>terminates the process, not just a thread.<br>
<br>AFAICT, Java doesn&#39;t have an equivalent of fork() (which doesn&#39;t exist<br>on Windows); the normal mechanism for creating processes is with<br>Runtime.exec(). I have no idea whether this is even permitted from<br>
within Tomcat, or whether there are any complications involved.<br><font color="#888888"><br>--<br></font>
<div>
<div></div>
<div class="h5">Glynn Clements &lt;<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>&gt;<br></div></div></blockquote></div><br>