| Author |
Multiple threads of a servlet instance and servletConfig
|
ganga rk
Greenhorn
Joined: Jan 11, 2011
Posts: 5
|
|
Each servlet has a unique servletConfig.
Does multiple threads of a given servlet instance share the same servletConfig object ?
Please respond....
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
Don't know. Doesn't matter. Since one only reads from the ServletConfig, and never writes to it, there are no multi-threading issues.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
M Nadeem
Greenhorn
Joined: Feb 10, 2011
Posts: 1
|
|
|
Right answer. ServletConfig is read only object. All of its properties are set by JSP/Servlet container. Access of multipal threads have no harm to Servlet Config.
|
 |
ganga rk
Greenhorn
Joined: Jan 11, 2011
Posts: 5
|
|
So when we have a situation like this:
" Many requests are coming in for a given sevlet A.
So the container would create threads of that servlet(A) for each request.
Now each of this thread would have a servlet config."
Now, would all the threads be having the same servlet config i.e will the container create only one servlet config for a servlet instance(for A in our case)and pass its copy to its threads?
Or will it create a servlet config for each of the thread?
|
 |
amit punekar
Ranch Hand
Joined: May 14, 2004
Posts: 491
|
|
Hi,
There is only one instance of the servlet and hence one instance of ServletConfig.
The threads that process the requests call the service() method of the Servlet which has one single instance.
The thread and the instance are two separate thing.
Hope this help you to clarify your understanding about the same.
Regards,
Amit
|
 |
bala rimmalapudi
Greenhorn
Joined: Feb 11, 2011
Posts: 7
|
|
|
Yes, Every servlet will have only one ServletConfig, and the same ServletConfig will be used by multiple threads of that specific Servlet.
|
 |
Kumar Raja
Ranch Hand
Joined: Mar 18, 2010
Posts: 458
|
|
|
Point to be noted here is one servlet per jvm..
|
Regards
KumarRaja
|
 |
 |
|
|
subject: Multiple threads of a servlet instance and servletConfig
|
|
|