aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Thread Safety Question? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Thread Safety Question?" Watch "Thread Safety Question?" New topic
Author

Thread Safety Question?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 8795

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?


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

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 ?


[My Blog]
All roads lead to JavaRanch
Sagar kanchi
Ranch Hand

Joined: Oct 07, 2005
Posts: 50
I think Class variables are static varibles and class refers to Servlet class itself.


Where there are more wonders there is less knowledge
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 8795

Yes, class variables are static servlet variables in the question's context!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

class variables are static servlet variables

Not thread safe then.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Thread Safety Question?
 
Similar Threads
Thread safety and cookie age question...
Thread safe
Using multiple threads
Threads,serialisation, static variables - java basic doubts
But is my API really useful?