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.
Ankur Jain Kothari
Joined: Feb 08, 2010
ya true..why not B? using STM means making instance variables thread safe
Do What You Wanna Be....Taking Things The Way They Come
scjp 1.6 91 percent, scmad 90 percent(rounded off to nearest integer)