I have a test of your method of simply putting
+ACI-maintenanceThread.shutDown()+ADsAIg- in the post method and putting a button in
the html page , it does stop the timed thread(as a test, I let it write the
counter to a file), but when I start the servlet again, it can not write the
counter to the file. I check the system information, it seems to be that the
maintenanceThread is running periodically.

Maybe the problem is that I didn'd use the Singleton to save the thread
instence, but I did not run the same servlet at the same time, so it is
still a question to me.


+AD4-I don't see point of having another servlet set the flag to true. If you
need
+AD4-automatic control of the timed servlet, then the timed servlet can do that
+AD4-itself (servlets can be implemented to handle multiple threads). Also, why
have
+AD4-the flag in a Singleton or in ServletContext? The flag can be a member
variable
+AD4-of the Servlet itself, one servlet, one flag (just remember to protect the
flag
+AD4-for concurrent access).
+AD4-
+AD4-If you need manual control, then the same servlet can handle that as well.
One
+AD4-of the main purposes of a servlet is to handle requests. Just define a
method of
+AD4-the servlet to handle a request to stop or control the maintenance thread.
When
+AD4-you submit a request, doGet or doPost passes the request to the controller
+AD4-method. Controller method sets the flag which tells the maintenance thread
what
+AD4-to do.
+AD4-
+AD4-Kevin Mukhar
+AD4-
+AD4-Randy Belknap wrote:
+AD4APg-
+AD4APg- You could put a flag in a Singleton or in ServletContext that the thread
+AD4APg- checks each time it runs.  If the flag is set, the thread dies.
+AD4APg-
+AD4APg- You would then have another servlet to set the flag to true.
+AD4APg-
+AD4APg- Jack Wang wrote:
+AD4APg- +AD4-
+AD4APg- +AD4- Hi,all,
+AD4APg- +AD4-
+AD4APg- +AD4- I have a timed servlet run in ISP machine in which JRUN is installed.
The
+AD4APg- +AD4- timed servlet will run automatically every 2 hours. My servlet is
developed
+AD4APg- +AD4- with Matt Tucker's CoolServlets.com's maintenanceThread.
+AD4APg- +AD4-
+AD4APg- +AD4- The servlet can be stoped by stopping JRUN, but JRUN is the service of
ISP,
+AD4APg- +AD4- which is not controlled by me. Now my question is how can I stop or
control
+AD4APg- +AD4- my timed servlet?

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to