>>1. Is it true that requests from the SAME client
>>always served by the SAME thread?
>
>Not always. Even if a servlet implements SingleThreadModel, the
>container may still keep a pool of instances of this servlet and issue
>requests as they come in, as long as no two requests share an instance
>at the same time (i.e. they'll process one at a time).
This is true in a very particular situation. Basically, a servlet container will
instantiate ONE servlet class into an object. Each request is handled via it's own
separate thread. Unless Servlet implements SingleThreadModel, all threads that are
directed to that particular servlet will activate it's "service()" method and run in
paralel. In the oposite case, threads will synchronize on that Servlet. If I
understand things correctly, it is not the servlet that creates threads for each
request - it is the particular Connector, which than forms the request and forwards it
to the appropriate handler, filter or a servlet.
So, the only occasion when the same thread would handle TWO requests, regardles of
who's the originating client, would be when there is a thread-pool and first request
finishes and the available thread for the other request is the one that handled the
first one. This is a game of chance. Again, I haven't looked into Tomcat internals,
but this is how I picture any servlet container would work.
>>2. What if the SAME client access 2 different servlets
>>in a servlet container? Is it still served by the SAME
>>thread?
>
>Not always.
Hardly ever, IMO, see above.
Nix.