This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes singlethread model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "singlethread model" Watch "singlethread model" New topic
Author

singlethread model

clyde melly
Ranch Hand

Joined: Sep 04, 2003
Posts: 152
if a servlet implements the singlethread model and suppose there are 10 requests,how many instances are created and how does the management for the request proceed.if the single thread model is not implemented then how many instances wud be created for the 10 requests as stated above.
unni krishna
Ranch Hand

Joined: Jul 14, 2004
Posts: 39
*** SingleThreadedModel is depricated. Now a days nobody uses it ****
If a servlet implements single threaded model, then one instance of that servlet can serve only one request at a time. The number of instances created can be specified by the user in web.xml.

If the servlet does not implement single threaded model, then with single instance, 10 requests can be served.


Software Engineer (SCJP)<br />USTechnology, CA
clyde melly
Ranch Hand

Joined: Sep 04, 2003
Posts: 152
so for 10 requests 10 instances ??? in which case implementing singlethreadedmodel?
unni krishna
Ranch Hand

Joined: Jul 14, 2004
Posts: 39
friend, dont use singlethreaded model. if u implement single threaded model, then the number of requestes that can be served at a time is equal to the number of instances of the servlet that you create.
clyde melly
Ranch Hand

Joined: Sep 04, 2003
Posts: 152
i get it but just wanted to know how does the request management happen with both approach in details
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Funny how many of the same people who disparage SingleThreadModel are happy with EJBs Having said that, I would agree: don't use SingleThreadModel (or the JSP equivalent). Write threadsafe code. It's not that hard.

- Peter
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: singlethread model
 
Similar Threads
How many Instances will be created?
singlethreadmodel
SingleThread Model
instances of an action class
how many servlet instances will be created