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 Static Variable in Servlet 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 "Static Variable in Servlet" Watch "Static Variable in Servlet" New topic

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: 9999

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:
subject: Static Variable in Servlet
It's not a secret anymore!