• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mock Question about thread-safe

 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are static variables thread safe?
 
reply
    Bookmark Topic Watch Topic
  • New Topic