File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Thread safe Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Thread safe" Watch "Thread safe" New topic
Author

Thread safe

Goan Balchao
Ranch Hand

Joined: Mar 25, 2002
Posts: 93
According to the information I gathered from reading the psecs the following elemnts are threadsafe.
1. Local variables
2. Instance variables
3. Request/Response attributes(because the request/response object is valid only in the currently executing thread)
and the non -thread safe elements are
1. Session attributes
2. Context attributes
3. Class variables
Am I correct? Have I left out any other elements?
ANy hellp will be appreciated.


Hemant Kamat<br />SCJP2<br />SCWCD<br />SCBCD<br />SCEA-I
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Instance variables of a servlet are not thread safe by default.
According to the specs:
For a servlet not hosted in a distributed environment (the default), the servlet
container must use only one instance per servlet declaration...A servlet container may send concurrent requests through the service method of
the servlet. To handle the requests the developer of the servlet must make adequate
provisions for concurrent processing with multiple threads in the service method.

In short, it's up to you to make instance variables thread-safe.
-anthony
 
IntelliJ Java IDE
 
subject: Thread safe
 
Threads others viewed
Which among the servlet objects are synchronized
Thread safety and cookie age question...
What is thread safe?
j2eecertificate.com question
Request Attributes Thread Safe?