• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static Variable in Servlet

 
Ritesh Raman
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is static variable in servlet Thread safe ? please explain.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only local variables are request attributes are thread safe. The rest are all subjected to manipulation by multiple threads unless you synchronize on them.
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ritesh Raman
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srinivasan and Jothi for your reply .
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!