Can getAttribute() method of Tomcat ServletContext implementation be called without synchronization?

Posted by oo_olo_oo on Stack Overflow See other posts from Stack Overflow or by oo_olo_oo
Published on 2010-03-30T10:48:37Z Indexed on 2010/03/30 10:53 UTC
Read the original article Hit count: 254

I would like to read some parameters during servlet initializtion (in init() method), and store them among servlet context attributes (using getServletContext().setAttribute()). I would like to read these parameters later - during some request processing (using getServletContext().getAttribute()). So, the multiple threads could do this simultaneously. My question is if such an attempt is safe? Could I be sure that multi threaded calls to the getAttribute() don't mess up any internal state of the servlet context?

Please take into account that I'm not going to call the setAttribute() anywhere besides the initialization. So, only calls to the getAttribute() are going to be done from multiple threads. But depending on the internal implementation, this also could be dangerous. So, any information about Tomcat's implementation would be appreciated.

© Stack Overflow or respective owner

Related posts about java

Related posts about tomcat