Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #2948

Re: Threads and statics

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Threads and statics
References <905p9gFpuoU1@mid.individual.net> <_8udnYBYP_NkLQDQnZ2dnUVZ_gGdnZ2d@earthlink.com> <e325cb5e-ca0a-4d8b-b865-1f5a5b06811e@x1g2000yqb.googlegroups.com> <b6408127-4a62-4bae-845d-ff2872427357@j13g2000yqj.googlegroups.com>
Message-ID <Rhqnp.36158$tL6.7871@newsfe03.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-04-07 18:47 -0300

Show all headers | View raw


On 11-04-07 12:20 PM, Lew wrote:
> 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

It's not, and in fact most occurrences of
ConcurrentModificationException I've seen are not in multi-threaded
situations, they are in single-threaded scenarios.

I sort of wish they'd come up with a different name than
ConcurrentModificationException; the exception usually has to do with
iterators in the presence of modification of the iterated thing, and the
name of the exception doesn't reflect that. If I don't have iterators
involved I can concurrently modify to my heart's content (although I
probably don't want to).

AHS
-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Threads and statics Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-07 13:34 +0100
  Re: Threads and statics Patricia Shanahan <pats@acm.org> - 2011-04-07 05:41 -0700
    Re: Threads and statics Robert Klemme <shortcutter@googlemail.com> - 2011-04-07 07:38 -0700
      Re: Threads and statics Lew <lew@lewscanon.com> - 2011-04-07 08:20 -0700
        Re: Threads and statics Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-04-07 18:47 -0300
  Re: Threads and statics markspace <-@.> - 2011-04-07 09:32 -0700
  Re: Threads and statics Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-07 21:14 -0400
    Re: Threads and statics Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-09 18:15 +0200
      Re: Threads and statics Lew <noone@lewscanon.com> - 2011-04-09 13:06 -0400
    Re: Threads and statics Patricia Shanahan <pats@acm.org> - 2011-04-09 09:29 -0700
    Re: Threads and statics Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-04-09 09:29 -0700
    Re: Threads and statics Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-09 14:57 -0400
      Re: Threads and statics "Mike Schilling" <mscottschilling@hotmail.com> - 2011-04-10 23:10 -0700
        Re: Threads and statics Tom Anderson <twic@urchin.earth.li> - 2011-04-11 13:25 +0100
          Re: Threads and statics Lew <noone@lewscanon.com> - 2011-04-11 08:58 -0400

csiph-web