dcsimg
If an object is referenced by a local variable -- is it safe from concurrency issues?!_NEWLINE_!
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Richard_Robinson
Posted On:   Sunday, April 8, 2001 12:41 PM

I'm not quite clear on this point.


I have a servlet with a local variable
in a method pointing to a utility object
in my class path.


The local variable is safe from
concurrency. But the utility object has
instance variables in it. Other servlets
also point to the same utility object
(it's a Java bean entity wrapping
a Database table).


Because the object is referenced by a
local variable -- is it safe from
concurrency issues?

If an object is referenced by a local variable -- is it safe from concurrency issues?!_NEWLINE_!

Posted By:   Alex_Chaffee  
Posted On:   Monday, April 30, 2001 04:47 PM

No. The local variable only holds a pointer to an object; if other threads can also point to this object, then it needs to be made thread-safe.

Re: Multithreading Servlets, local vars, and !_NEWLINE_!utility classes

Posted By:   Michael_Wax  
Posted On:   Sunday, April 8, 2001 01:19 PM

If your servlet were creating an instance of a class, then that instance would be thread-safe. However, if I understand your question correctly, your servlet is getting an instance of an entity EJB. In that case, all of the servlets are sharing the same object, so that more than one could be modifying instance variables in the object at the same time, i.e., you are not safe from concurrency issues.
About | Sitemap | Contact