Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

10 clients requests for a Servlet.How many servlet instances are created [duplicate]

Suppose 10 clients requests for a Servlet. How many servlet instances are created? Also will it create any concurrency modification problem if each instance is trying to make changes? Please help.

like image 936
user1281029 Avatar asked May 14 '12 04:05

user1281029


People also ask

How many instances of servlet are created?

Usually only one instance of the Servlet object is created. But some advanced containers might create more than one instance under certain circumstances. Even so, there is a difference between static class variables and instance variables.

How many servlet instances are created when multiple requests arrive simultaneously?

You are right, Only single instance of Servlet is created, but that instance is shared across multiple threads.

How many servlet objects are created for multiple requests?

1) How many objects of a servlet is created? Only one object at the time of first request by servlet or web container.

How many servlet instances are created in the servlet lifecycle?

2) Servlet instance is created The servlet instance is created only once in the servlet life cycle.


1 Answers

Only one instance of servlet exist (per classloader) , and each request will be served on its own thread

So is there any thing that is shared amongst requests you need to manage synchronization

like image 76
jmj Avatar answered Oct 02 '22 01:10

jmj