struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: OT: Thread pool samples
Date Thu, 04 Sep 2008 17:53:40 GMT
Zoran Avtarovski wrote:
> I¹m trying to implement a simple thread pool model (Java 1.4) for a
> telemetry application.
> 
> I¹m getting up to speed with threads but I haven¹t been able to find any
> examples of setting a thread pool in a server/servlet environment.
> 
> I have a number of remote units which upload telemetry data for processing
> via http and receive instructions via the response. The instructions aren¹t
> dependent on the results of data processing. At present I fire off a new
> thread to process the data for each unit, but it makes sense the best
> approach would be to have a fixed pool of threads and then add the data to a
> queue which is processed by the pool of threads.
> 
> It¹s setting up the initial pool that I¹m a little unclear about. Do I setup
> a Threadpool servlet and set it to load on startup and store the pool in the
> application scope?
> 
> Any advice or pointers to some good information would be appreciated.

When working with threads in a web application, you should be aware that 
the Servlet specification recommends against creating new threads at 
all... AFAIK, it works in most (all?) containers, but you have to be 
careful about cleaning up properly etc.

That said, it sounds like you probably just need a task scheduling 
library such as Quartz. Such libraries should already have provisions 
for managing 'runaway' threads, cleaning up and releasing resources, etc.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message