Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Additional thread on a POJO called from a Servlet - What would happen?

 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing you do on the local system will have an effect on the thread.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also use the Java task execution framework
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic