| Author |
Additional thread on a POJO called from a Servlet - What would happen?
|
Michael Cropper
Ranch Hand
Joined: Sep 30, 2009
Posts: 137
|
|
Hi all,
Wondering what would happen in the following circumstance. What I am about to describe has just been set up so looking for a better understanding of what would happen.
1) Access www.website.com/mypage from my personal computer (the website is hosted on a server in some distant land somewhere)
2) 'mypage' maps to MyPageServlet.class
3) This Servlet then calls 'MyPojo.class' in another thread as the full duration of this tasks is ~10hrs.
What would happen if I was to close my browser and my personal computer? Would the additional thread within 'MyPojo.class' stop running? I am guessing not, since once this has started then it has started and needs to finish.
Just wanted to check with the experts since I don't want this process to stop half way through if I turn my computer off :-) (would have been ideal for me to think through this before running the program mind... but hey)
Thanks
Michael
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
|
Nothing you do on the local system will have an effect on the thread.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
|
Whether it's a good idea or not is another question. To make sure that the web app is always responsive, I almost always delegate intensive or long processing to a daemon program.
|
 |
Michael Cropper
Ranch Hand
Joined: Sep 30, 2009
Posts: 137
|
|
Thanks for the quick reply. Good to have it confirmed that it wouldn't have any impact.
As for if it is a good idea or not... at the moment it doesn't harm performance as the web app hasn't got high traffic. As traffic / load increases then I will likely look at placing this long running program on a separate web server (e.g. long-running-program.website.com). Not got experience with the Daemon stuff at the moment, but it is good to know that is an option as well (I'll add it to the reading list :-) )
Thanks
Michael
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4115
|
|
|
You could also use the Java task execution framework
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
 |
|
|
subject: Additional thread on a POJO called from a Servlet - What would happen?
|
|
|