How can context attributes be made thread safe?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
How can context attributes be made thread safe?
Rating:
Context attributes are not thread safe, since multiple servlets and hence multiple threads in a Web-app can access these attributes. To make a context attribute thread safe, it is necessary to apply a lock on the context. This is done by synchronizing the ServletContext, so that when a thread holds a lock on the context, no other thread can access it. If any other thread tries to access the context attribute, it has to acquire the lock on the context.
Rating:
Was this information helpful?
Other articles
- What is the getRemoteAddr() method?
- What are the methods available in HTTP 1.1?
- What is the directory structure of a WAR file?
- Skills required for Sun test CX310-081
- What is the getParameterValues() method?
