• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread safety ?

 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a context attribute which is set only in one servlet and accessed in many jsps.
how do i make this attribute thread safe.



i am also looking for some multi-threading tutorial for servlet and jsp
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My suggestion would be to either synchronize on ServletContext or synchronize on the ArrayList stored in the Context and then make changes to the ArrayList.
 
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!