aspose file tools*
The moose likes Servlets and the fly likes Additional thread on a POJO called from a Servlet - What would happen? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Additional thread on a POJO called from a Servlet - What would happen?" Watch "Additional thread on a POJO called from a Servlet - What would happen?" New topic
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: 61413
    
  67

Nothing you do on the local system will have an effect on the thread.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

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: 4699
    
    7

You could also use the Java task execution framework


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Additional thread on a POJO called from a Servlet - What would happen?