• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple Threads to access a value  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,
Ruchi.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!