• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple threads of a servlet instance and servletConfig

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each servlet has a unique servletConfig.
Does multiple threads of a given servlet instance share the same servletConfig object ?
Please respond....
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. Doesn't matter. Since one only reads from the ServletConfig, and never writes to it, there are no multi-threading issues.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Every servlet will have only one ServletConfig, and the same ServletConfig will be used by multiple threads of that specific Servlet.
 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Point to be noted here is one servlet per jvm..
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic