This week's book giveaway is in the Android forum.
We're giving away four copies of Android Programming: The Big Nerd Ranch Guide and have Bill Phillips & Chris Stewart on-line!
See this thread for details.
Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mock exan question  RSS feed

 
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!