permaculture playing cards
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Multiple Threads to access a value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Multiple Threads to access a value" Watch "Multiple Threads to access a value" New topic

Multiple Threads to access a value

Ruchi Kumar

Joined: Feb 16, 2005
Posts: 7
This is with reference to HFS, Pg 202, last Q <There are no Dumb Qs>

To my understanding, this mentions ways in which multiple threads can access a common value. But then it says:

"1. Declare the variable as a local variable within the service method, rather than as an instance variable..."

I thought that local varibales are thread safe, and instance variables were not, so inorder for multiple threads [I] to [I]sharethe value, shouldn't the variable be as an instance variable. ie: shouldnt 'instance variable' and 'local variable' be swapped in teh above sentence in the book ? Or am I missing some point?

I looked up the errata, couldn't find any related to this point.
Please help me with this query, as the concepts get mixed up otherwise.

P. Dunn
Ranch Hand

Joined: Feb 22, 2005
Posts: 34
I think your right. What they're trying to accomplish is unclear from the question. Are they trying to share a variable or a value? That's what is muddled.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Multiple Threads to access a value
It's not a secret anymore!