Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock exan question

 
Dave Teare
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question:
Which of the following are considered ThreadSafe?
context attributes
class variables
request attributes
local variables

The question asks for 2 answers, but is there not only one correct answer, namely local variables?
Thanks for any insight!
--Dave.
 
Jagdeep Singh
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct answer is "Local variables" & "Request variables". Servlet request object is accessed by only one thread because container creates a new ServletRequest object for each request it receives. Since only one thread service the request at any time, request scope is thread safe and so are variables there in. ( Assuming we are no creating threads in doXXX() methods ).
 
Hafizur Rahman
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jagdeep Singh.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic