tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bo Xu>
Subject Re: Scheduling tasks in Tomcat
Date Fri, 12 Oct 2001 19:29:02 GMT
Josh Knowles wrote:

> You could create an object which gets started when tomcat starts that just
> runs a low priority thread and sleeps for n minutes then executes a chunk of
> code.  Depending on what version of Tomcat you are running you need to
> either add the servlet to your web.xml file within a <load-on-startup> tag
> or you can use the new Application Event Listener to listen for startup and
> shutdown.
> ~josh
> -----Original Message-----
> From: Vara Prashanth []
> Sent: Friday, October 12, 2001 10:52 AM
> To:
> Subject: Scheduling tasks in Tomcat
> Hello all:
> Does any version of tomcat have facilities for scheduling tasks? Say I have
> a piece of code that I want to run once every two or three hours.....does
> tomcat provide any features like windows to schedule tasks? I mean I could
> do it with windows...but I was just curious if tomcat had the
> implementation!
> Thanks
> Prashanth
> [...]

just a suggestion :-)  I think if you use such a Thread in Servlet,  perhaps it
is better
to do the following:
    * in any time, this object is "Singleton style", i.e., there is only one
such object in
      any given time point
    *  make the (Runnable)class of this object NOT be loaded by webapp
       I think this can avoid the following:
          if the old webapp classloader which loads this class is destroyed by
         or "managment of Servlet container(for example, for memory issue)",
that object
         will lost its classloader(and its Class object)

        for example, this class can be put into:
        %CATALINA_HOME%/classes/    Unpacked classes global to web applications
        %CATALINA_HOME%/lib/           Classes in JAR files global to web
           Unpacked common classes available to both Catalina internal classes
and web applications:
            Common classes in JAR files available to both Catalina internal
classes and web applications:

BTW, in Servlet-List, there are also several emails about it.

Oct.12, 2001

View raw message