Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Recommended way of using a Timer in jetty?

Hi,

I have a webapp, and I want to create a repeating timer which will do some work every so often. Right now I'm doing it from a startup servlet like this:

    public class ServletStartup extends HttpServlet {

        public void init(ServletConfig config) 
  throws ServletException 
  {
            Timer timer = new Timer();
timer.scheduleAtFixedRate(
  new TimerTask() {
  public void run() {
                        ...
  }
  }, 
  1000, 10000);
        } 
    }   

I'm not sure if this is ok - is there a recommended way of doing it? 

Thanks

Back to the top