This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Safe

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following are thread Safe
request attributes
response Object
local variables

Following are not thread Safe
servletcontext attributes
session attributes
instance variables

What about ServletConfig parameters?
Are they access by multiple threads at a single time?
i know ServletConfig parameters are Read Only constants.

Thanks
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletConfig Parameters are readonly then i think it doesn't matter
 
Elan Ram
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, we can set only the attributes. Not parameters. There are no setter methods to set the same.
Hence, Thread safety is applied only to attributes and not a paramters.
 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More to note ...

As said, Parameters are thread-safe as there are no setters for the same.

Only in SingleThreadModel, instance variables are thread-safe.

Static Variables, Context Attributes and Session Attributes are never thread safe.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
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!