Are local variables in static methods thread local?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Balthasar_Glaettli
Posted On:   Tuesday, June 25, 2002 11:48 AM

take a simple class that has a static method. My simple -maybe easy - question is: Are variables that are local to the method code block (i.e. that do NEITHER refer any static properties of the class NOR hold references to any external objects ) really thread save (without explicit synchronisation)? From online tutorials etc. about Multithreading I learned the following: While executing, the process has access to certain data. In Java, there are three types of data a process can access: local variables are accessed from the thread's stack, instance variables are accessed through object references, and static va   More>>

take a simple class that has a static method. My simple -maybe easy - question is:


Are variables that are local to the method code block
(i.e. that do


  • NEITHER refer any static properties of the class
  • NOR hold references to any external objects

) really thread save (without explicit synchronisation)?


From online tutorials etc. about Multithreading I learned the following:


While executing, the process has access to certain data. In Java, there are three types of data a process can access: local variables are accessed from the thread's stack, instance variables are accessed through object references, and static variables are accessed through class or object references. ( Source )


So I guess the answer to my question must be YES. However I have to be 100% shure (and none of the examples/explanations I found treated a static method).

   <<Less

Re: Are local variables in static methods thread local?

Posted By:   Anonymous  
Posted On:   Tuesday, June 25, 2002 01:16 PM

The answer is yes.
About | Sitemap | Contact