Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Jesper de Jong wrote:Are you using a web app framework?
Jesper de Jong wrote:
What is MultiActionController?
Jesper de Jong wrote:
If you would do this in a servlet, then it could be a problem. The servlet container manages creating instances of servlets, and for whatever reason it may decide to create one or more instances of a servlet. If it would create multiple instances, then each of them would have their own ExecutorService instance.
Jesper de Jong wrote:
Another problem is that you'll never get a chance to shutdown the ExecutorService.
Jesper de Jong wrote:
If you would stop your webapp (for example in Tomcat's manager application), then the threads started by the ExecutorService would continue to exist and run. So it would be a resource leak.
Tim Holloway wrote:Since we don't have all the context here, we can't offer advice on all the details,
Thats a valid point, I'll check into using ServletContextListener for this.Tim Holloway wrote:
1. You should NEVER spawn threads or thread pools from within the execute() method of a servlet, its heirs (doGet(), doPost(), etc. or any class or method invoked from a servlet. That includes JSPs and action classes for such framworks as Struts, JSF, Wicket, and so forth. If you want thread pools, create them from a ServletContextListener, where you won't pollute the request/response thread pool that's handling servlet requests.
I have analyzed this, the working here is that besides a few params sent by the client in request object, rest is provided by spring itself. I could mark the variables as final and pass them to this anonymous Runnable class.Tim Holloway wrote:
2. DON'T attempt to save HttpServletRequest and HttpServletResponse objects outside of the execute() method of a servlet or its heirs and assigns. Those objects are only valid for the duration of the servlet request method. Same goes for other internal resources like JDBC Connection objects.
salvin francis wrote:Ahh this is something that struck me as well... When do I actually shut it down ? I don't have an answer to that, need to research.
Yes, but then these threads are quite shortlived, they would complete their tasks within a few secs. However, in short the answer is yes, it would be a resource leak in the event a thread is executing when the Tomcat is shutdown.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Yes, but its a tradeoff that a user gets a faster response when saving an entry.Stephan van Hulst wrote:You realize that performing more tasks in parallel is going to increase memory usage?
I figure that this can be used to get a reference to a bean that's managing my threads. But, I am still a bit confused as to when do I actually shutdown the pool ?Tim Holloway wrote:I believe, however, that you can obtain the Spring Bean factory from the Spring Application Context and use that to obtain Spring-managed resources.
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|