Suppose, this is in any
I clicked a button to calculate something, and the process will be done in a few steps or by using some synchronized threads that need nearly 5 hours.
If I close the browser window after a click, what will happen?
Will the calculation process stop or continue?
If its the latter (continue), and I log in to my account after 2 hours, what will I see?
I want to see the calculation progress real time.
What should i do?
This kind of processing requires planning. There are many edge cases. What if the process is already running? What to do if the server terminates in the middle of processing? Can you restart? Can the processing be interrupted? Can every user start this processing, or just authorized ones?
Ok, now to an answer. You want to run the processing in a separate, background thread. See the Executor classes. Then you have to store the progress of that processing somewhere (think db here) and create another page to show that progress. You may also have to remember the user that started the processing, so that you know which of the progress information to show to the user requesting the progress.
So, simple! :)