Ummmm errrr...sure you could do that but you should ask yourself "is this
the right thing to do?"  If the sample code you provided is similar to what
you're trying to implement I would recommend that you right your own
Runnable object and control it's lifetime using a ServeltContextListener
object.  Or at least define the Runnable object as a private inner class of
the Servlet so you're not exposing a public method that isn't intended to be
called from outside the servlet.  Just my 2 cents...

Jeremy

> -----Original Message-----
> From: micael [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 08, 2002 5:17 PM
> To: Tomcat Users List
> Subject: Threads of Control
> 
> Can a servlet start an application on a server which is available to a
> user
> on the server machine?  Something, i.e., like the following:
> 
> import java.io.*;
> import java.util.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> public class AppCtrl extends HttpServlet implements Runnable {
>    private boolean change;
>    private Thread ctrl;
>    private App [] app;
> 
>    public void init() throws ServletException() {
>      ctrl = new Thread(this);
>      ctrl.setPriority(Thread.MIN_PRIORITY);
>      ctrl.start();
>    }
> 
>    public void run() {
>      while(true) {
>        if(AppProps.change()) {
>          app = AppProps.changes();
>          for(int i = 0; i < app.length; i++) {
>            AppManager.implementChange(app[i]);
>            try {
>              ctrl.sleep(200); // .2 second break between changes.
>            } catch (InterruptedException ignored) {
>            }
>          }
>        }
>      }
>    }
> }
> 
> 
> Micael
> 
> -------------------------------------------------------
> 
> This electronic mail  transmission and any accompanying documents contain
> information belonging to the sender which may be confidential and legally
> privileged.  This information is intended only for the use of the
> individual or entity to whom this electronic mail transmission was sent as
> indicated above. If you are not the intended recipient, any disclosure,
> copying, distribution, or action taken in reliance on the contents of the
> information contained in this transmission is strictly prohibited.  If you
> have received this transmission in error, please delete the message.
> Thank you
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:tomcat-user-
> [EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to