> Maybe do a sleep instead of busy waiting (looping takes up 
> too much cpu
> time).
> 
> > > How about running an application that periodically posts to
> > > the servlet?
> > >
> > >
> > > > How can a servlet be automatically be invoked by
> > > > itself, say peroidically?
> > > > Usul
> >
> > I think a better way is to write a servlet which is configured
> > as a load on startup servlet which forks a separate "scheduler"
> > thread which then defines tasks to be completed at specified
> > interval(using a properties file or init params...).  The
> > Thread(Runnable) will essentially be a infinite loop which will
> > check to see if it's time to run certain tasks. i.e.
> >
> > while(1) {
> >     if ( /*somethings true 1*/ ) {
> >         /*perform task 1*/
> >     }
> >     if ( /*somethings true 2*/ ) {
> >         /*perform task 2*/
> >     }
> >     // ...
> > }

Yeah, that's the general idea.  That was the //... part any additional
cleanup between states and a wait state.  Otherwise the process, depending
on the performance of your separate scheduled jobs and the frequency of
them, could pretty much lock the processor down.  This is meant as a
rudamentary example.  This is the generic model of a scheduling
thread/server.


---
Michael Wentzel
Software Developer
Software As We Think - http://www.aswethink.com

Reply via email to