| Author |
Are static methods that don't use class variables safe?
|
bengt hammarlund
Ranch Hand
Joined: Oct 17, 2003
Posts: 78
|
|
If I have a static method that only uses internal variables or variables that came as parameters on the function call, this function is thread safe? I mean, these internal function values are stored in the calling thread's stack or other place? Imagine this (useless) method: and the calling thread's run() method: Thanks in advance for any reply!
|
<b><i>Bengt Hammarlund</i><br />� Sun Certified Java Programmer</b>
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
|
Yes, as long as you're not using any resources that might be shared by two threads - static member variables, other objects - you should be fine. I prefer not to talk about things like "stack space" but the idea that parameters and local variables in a method are in their own private space and scope is right & good.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: Are static methods that don't use class variables safe?
|
|
|