I’ve been making a Vaadin web application these last few weeks and so far it’s been great. However, I’ve run into a big hurdle that I can’t seem to get over.
I am running an application on the server which needs to process a few tasks. In this case this process takes ~5 minutes. Now obviously I don’t want my user to spend 5 minutes looking at a pop-up, so I want to place this process in a separate thread. This is what I have now:
class RunScenario implements Runnable {
Collection collection = stuff for collection;
EngineService engineService = new EngineService();
However, when I run “new RunScenario().run()” my browser is still showing the loading bar until the process is done. Then it finishes with the other tasks and closes the pop-up.
I dont see what I’m doing wrong, maybe I’m implementing this incorrectly? I could use some advice.
my problem fits to the title “Running threads in background”.
I want to have a background thread, which runs independent from any session. I only found the following approach, not independent from any session and not working very long. The timer process starts with the first session:
This works over the day if there are sessions. Then at some time it stops (I think after the last session is destroyed) and it does not start again with a new session. I don’t find any error messages in the logging.
Can anyone help? What are my mistakes? How to set up such a static background process?
seems to me you could use some scheduling tool, e.g. Quartz is an easily configurable tool for this
http://quartz-scheduler.org/ . If the background process is independent from the UI, I would keep it separate from the UI code - that said, of course you can add/remove/start/stop these timers from the UI if needed.
thank you for your hints. The solution was to find and to eliminate all connections to the UI. The ScheduledExecutorService makes his job now. It only updates container extended from IndexedContainer. That works now.