Dunith Dhanushka Dunith Dhanushka - 1 year ago 125
Java Question

Java Servlets threading model

I was wondering if anybody could explains me the threading model of Java Servlets?
As I understood about that, there is only one instance of a servlet can be existed in the servlet container and if muliple threads happens to be waiting for that servlet, there requests are serialized in some manner.
I don't know how that serialization process happens...

Can anybody explain it?

Answer Source

If requests were handled serially by servlets, then web applications would be very slow. It's actually the case that servlets need to be thread-safe, because a single instance of a servlet can be responsible for handling multiple requests simultaneously.

Usually a web application container will maintain a thread pool for handling requests, with incoming requests being assigned to threads on an on-demand basis.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download