[Biojava-l] Java servlets question

Thomas Down td2@sanger.ac.uk
Mon, 9 Jul 2001 09:35:10 +0100


On Sun, Jul 08, 2001 at 11:54:53PM +0100, David Huen wrote:
> Now that I've almost got RagbagDataSource working fully in Dazzle, I'm
> beginning to think about effieciency issues with RagbagDataSource.
> 
> Can someone tell me how many instances of the DataSource could potentially
> be created?  Is there only one an all requests for that datasource get
> channeled to it or are more instantiated when there is an incoming request
> and the there is no idle instance?
> 
> I ask because the Ragbag data structure is in-memory and I'd really like
> to avoid creating multiple instances of it as initialisation is slow.

Java servlets work by a threading model -- a single servlet
handles all incoming requests, so there are no memory problems.
The only caveat is that you /are/ expected to write threadsafe
code.

(Actually, there's an alternative model -- Servlets implementng
the SingleThreadModel interface will only be passed a single
request at a time, and the container MAY maintain a pool of
servlet instances.  DazzleServer doesn't use this, though -- indeed,
I don't know of many servlets which do).

   Thomas.