This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
The moose likes Servlets and the fly likes Which Attribute Scopes Are Thread-Safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Which Attribute Scopes Are Thread-Safe?" Watch "Which Attribute Scopes Are Thread-Safe?" New topic

Which Attribute Scopes Are Thread-Safe?

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Which ones of the following are thread-safe ( with my tempted answers )? Please kindly correct me with reasons.
1. local variable: yes
2. instance variable: no
3. class variable: no
4. request attribute: no
5. session attribute: yes
6. context aattribute: no
Rama Raghavan
Ranch Hand

Joined: Aug 22, 2001
Posts: 116
In my quest for knowledge I think -
If you implement SingleThreadModel then class variable would be thread safe (but not instance variable).

Rama Raghavan<br />SCJP2<br />SCWCD
I agree. Here's the link:
subject: Which Attribute Scopes Are Thread-Safe?