This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Static Variable in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Static Variable in Servlet" Watch "Static Variable in Servlet" New topic
Author

Static Variable in Servlet

Ritesh Raman
Ranch Hand

Joined: Jun 20, 2005
Posts: 34
Is static variable in servlet Thread safe ? please explain.


Thanks,<br />--------<br />SCJP 1.4
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9796
    
    2

Only local variables are request attributes are thread safe. The rest are all subjected to manipulation by multiple threads unless you synchronize on them.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Instead of giving the answer I will just guide you

1. what is a Class variable ? how it is different from instance variable ?

2. what thread safety ?

3. By the time you reach point you yourself can judge.

Hope this is good way to learn.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Ritesh Raman
Ranch Hand

Joined: Jun 20, 2005
Posts: 34
Thanks Srinivasan and Jothi for your reply .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static Variable in Servlet