Since only one Instance of Servlet is present for whole application,
We have take certain consideration while having thread safety.
Request Scoped attribute is thread safe.
You can implement SingleThreadModel interface but i recommend
you to use synchronized blocks.
You can implement SingleThreadModel interface but i recommend you to use synchronized blocks.
You're right that one absolutely should not use SingleThreadModel, but synchronization is only one tool of many in the Java language's arsenal for making things thread-safe. Others are volatile, ThreadLocal and the classes in the java.util.concurrent package hierarchy. I recommend to read up on Java concurrency to fully understand the issues and solutions; see the http://faq.javaranch.com/java/ThreadsAndSynchronizationFaq for links to the two excellent books available on the topic.