Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock Question about thread-safe

 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web .com developers choose to avoid using SingleThreadModel, but wants to ensure data is updated in thread-safe manner.
which 2 support this design goal..? (choose 2)

A. Store the data in the local variable
B. store the data in an instance variable
C. store the data in the ServletContext object
D. Store the data in the ServletRequest object

what's the answer you think???

Store the data in local variable would make sense...then how about another one???
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only local variables and request scope attributes are thread safe in servlet life cycle.
so my answers are
1)local variables &
2)request scoped attributes
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread safe

* local variables
* request attributes

Not Thread safe

* instance variables
* class variables
* session attributes
* context attributes

Hope this is useful
 
erwin jeffrey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are static variables thread safe?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic