Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Safety Question?

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is also from Javaranch,

Which of the following are considered Thread Safe?

1) Local Variables

2) Class Variables

3) Context Variables

4) Request Variables?

I choose 1 and 2. Am I right?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. 1 and 4. Only method local variables and request variables are thread safe. I don't like the "Class Variables" thing What class is this ? The servlet class ?
 
Sagar kanchi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Class variables are static varibles and class refers to Servlet class itself.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, class variables are static servlet variables in the question's context!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class variables are static servlet variables

Not thread safe then.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic