Timer

Hi
I was wanting to implement a timer on the server that would periodically fire an event but i want it to be a system-wide polling thread, so that there is only one running on the server and all ui’s use that timer if needed. I realise that if it is in the ui then a new thread is created with each ui instance. So i’m not sure where to put it. In the class that extends Vaadin Servlet, as in in the servletInitialized method? If so not sure how to get the event out of there into a class that can use it.

Thanks

I wouldn’t implement my own implementation. Have you checked Quartz?
http://www.quartz-scheduler.org/

Thx Johannes. I’ve lost my account details so can’t get back in so using a coworkers account. Quarz looks slick but im just wanting something as simple as

TimerTask tt = new TimerTask() {

        @Override
        public void run() {
            try 
            {
                //Fire event that all ui's can access
            } 
            catch (Exception ex) 
            {
                System.out.println(ex.toString());
            }
        }
    };
    Timer t = new Timer(true);
    t.scheduleAtFixedRate(tt, 0, 10000);

that can be started at servlet startup, not for each ui

I’ve just decided to use the pollListener event in the UI to fire off events on a polled interval. Seems to work ok