First of all you should never use SingleThreadModel interface. HttpServletRequest objects are threadsafe by default. Local objects or variables(inside service method) are threadsafe. ServletContext are not threadSafe even if you implement SingleThreadModel HttpSession objects are not threadSafe even if you implement SingleThreadModel. Instance variables(variables inside class but outside service method) are not threadSafe. Static variables are not threadSafe.
Gowher Naik wrote:
Instance variables(variables inside class but outside service method) are not threadSafe.
Given that this question involves using SingleThreadModel (STM). I think even B is a valid option here. With STM even instance variables are rendered thread safe.
Now in HFSJ 2nd edition it is given that vendors can implement STM in two ways
1) Using queuing, where each thread is made to wait for "the one" servlet instance. In this case instance variable is definitely thread safe
2) Multiple instance of servlet are made available in a pool and each request is directed to individual instances (with only one thread per instance allowed). Now in this case instance variables are NOT thread safe since at parallel many threads are accessing it.
So since implementation is vendor-dependent, is this the reason why option B is NOT considered valid here OR I am confusing lots of things here ??
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.