File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock Question about thread-safe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock Question about thread-safe" Watch "Mock Question about thread-safe" New topic

Mock Question about thread-safe

Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
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???

From NickyEng
Diploma in Computer Studies
SCJP 1.4
Formula 1 app by Maxis (Playbook)
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
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

Joined: Nov 15, 2004
Posts: 1026
Thread safe

* local variables
* request attributes

Not Thread safe

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

Hope this is useful

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
erwin jeffrey

Joined: Jun 29, 2011
Posts: 10
are static variables thread safe?
I agree. Here's the link:
subject: Mock Question about thread-safe
It's not a secret anymore!