[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: servlets are multithreaded, right?




> -----Original Message-----
> From: Chris Abney [mailto:chrisabney@charter.net]
> Sent: Tuesday, October 28, 2003 11:54 PM
> To: ajug-members@ajug.org
> Subject: Re: servlets are multithreaded, right?
> 
> I believe this is how it goes:
> The servlet itself is basically passive.
> The web server spawns new threads and that calls servlet class methods.
> So you can say - Tomcat, Jetty, ServletRunner, or whatever is the multi-threaded 
> part of the architecture.
> However, it is always the programmer writing servlet code that has to deal with 
> concurrency issues.

You are making sense.  The servlet developer is concerned with reentrant vs non-reentrant code.  I'm not up to date on the spec, but I don't recall any requirements which state that the servlet container is or is not multi-threaded.  The requirement is that the container guarantees SingleThreadedModel servlets are never entered by more than 1 thread at a time.  Has the servlet spec changed here?

A better question to ask on an interview is : 
When is it appropriate to use the SingleThreadedModel interface?

Kit