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


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

Re: Threads and statics

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: Threads and statics
Date Sat, 09 Apr 2011 13:06:38 -0400
Organization albasani.net
Lines 36
Message-ID <inq3m6$4cg$1@news.albasani.net> (permalink)
References <905p9gFpuoU1@mid.individual.net> <inlnjn$6c1$1@dont-email.me> <deadlocks-20110409180331@ram.dialup.fu-berlin.de> <inq0m4$429$1@dont-email.me> <resources-20110409182133@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.albasani.net 1fH9lRisqkyYhYXUbdUic1XxLGoqDuieTLOqsnR3lff6ZqE9duEw7+YUHlloaXYhzEgRl0QwpZ/noKgfjOQO9A==
NNTP-Posting-Date Sat, 9 Apr 2011 17:06:14 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="rO/+sza3CDpa/gjkgn+v2t8o9DTNES5eNW6qC/+Mr9Ay5GRTli8TQ3mAQV9JWwrw98i19q908rNcN9BxXzOPi6cBbl9Wpwvu+nwOHI8dpfq0kNr83WklfPesjXgipSeh"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8
In-Reply-To <resources-20110409182133@ram.dialup.fu-berlin.de>
Cancel-Lock sha1:rsAYQXcEyk94urhaMuLi/YgNtko=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3014

Show key headers only | View raw


Stefan Ram wrote:
> Daniele Futtorovic writes:
>> That's a tautology. But there *are* cases where you need exclusive
>> access to more than one resource at the same time.

>    Inventing freely without knowledge, I would first try to pack
>    such resources into a single »meta resource«, which then can
>    be obtained or released by a single atomic action, again.

>> The very fact that multi-threaded programs exists proves one
>> can avoid deadlocks in such cases -- no need to look any
>> further.

>    Then, the existence of erroneous programs would prove what?
>
>    For the meaning of the verb »prove« in software engineering,
>    see for example this report:
>
> http://machineslikeus.com/news/building-safety-nets-critical-systems
>
>    .

The book /Java Concurrency in Practice/ (informally, JCIP) by Goetz, et al., 
shed light on these issues for me.

If there is a well-defined order of acquisition for multiple locks, you can 
avoid deadlock.  Trouble arises when acquirers act in different sequence, 
e.g., one grabs A then B, whilst another grabs B then A.

One lock for multiple resources is another pattern in the book.  It goes into 
detail on how to reason about such scenarios.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

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