Page 1 of 1

about question enthuware.jwpv6.2.750

Posted: Tue Jul 24, 2012 5:09 am
by vgarg
per explanation (and my understanding as well) only "baz" variable is thread safe.
while the question says there are 2 correct options.. please explain.

code snippet:
---------------
import ...;
public CrazyServlet extends HttpServlet
{
private StringBuilder foo = new StringBuilder();
private static StringBuilder bar = new StringBuilder();
public void service(HttpServletRequest req, HttpServletResponse res)
{
StringBuilder baz = new StringBuilder();
HttpSession session = req.getSession();
}
}
-----------

Re: about question enthuware.jwpv6.2.750

Posted: Tue Jul 24, 2012 8:41 pm
by admin
As the explanation notes, request is considered thread thread safe as well.

HTH,
Paul.

Re: about question enthuware.jwpv6.2.750

Posted: Tue Aug 28, 2012 9:11 am
by viva
In the explanation:
"For a servlet that does not implement SingleThreadModel:

Thread Safe: request, response and local variables.
Rest all are unsafe.
"

When we have asynch processing request is not thread safe (and maybe response?)

If this is correct for request then maybe option 3 must be wrong.

Re: about question enthuware.jwpv6.2.750

Posted: Tue Aug 28, 2012 3:53 pm
by viva
sorry ignore my last sentence about option 3

Re: about question enthuware.jwpv6.2.750

Posted: Thu Aug 30, 2012 7:56 pm
by admin
You are right. This has now been fixed.
Thank you for your feedback!