Re: [ljc] Fwd: [concurrency-interest] Double Checked Locking in OpenJDK

From: Jack S.
Sent on: Monday, August 20, 2012 7:10 PM
It's been bugging me for quite a few years, and I came to the conclusion 
the only way to do it easily is with a language that makes it impossible 
to write race conditions. If you know of one that isn't too esoteric, 
I'd be interested. Otherwise, we're stuck with Java as the next best option.
-Jack

On 20/08/[masked]:36, Ben Evans wrote:
> People always seem to be interested in hearing about concurrency.
>
> This post from Doug Lea is an excellent summary of how to approach
> concurrent programming, and I thought the group might be interested in
> discussing it.
>
> Thanks,
>
> Ben
>
> ---------- Forwarded message ----------
> From: Doug Lea <[address removed]>
> Date: Thu, Aug 16, 2012 at 11:25 AM
> Subject: Re: [concurrency-interes­t] Double Checked Locking in OpenJDK
> To: [address removed]
>
>
> On 08/16/12 02:10, Zhong Yu wrote:
>> We are probably discussing two very different types of programs that require
>> different considerations:
>
> There are *many* cases, some of which have more efficient solutions
> than others. You are not likely to find too many simple slogans
> beyond:
>
> 1. When possible, use design patterns that allow
> java.util.concurrent­ (and/or other libraries/frameworks­) to do
> all the work for you in ensuring correctness and efficiency
> without you dealing with it at all. (Simple examples include
> Producer/Consumers and registries based on ConcurrentHashMaps.)­
>
> 2. Otherwise, when possible, keep objects/data isolated within
> threads/tasks.
>
> 3. Otherwise, when possible, stay within the bounds of simple
> idioms including: final fields for immutable data; AtomicX's
> (with compareAndSet) for reliably updatable single variables,
> latches/phasers for barriers, etc.
>
> 4. Use locks (either library-based or builtin) for most
> everything else.
>
> There are and always will be cases that fall outside these.
> Concurrent/parallel programming is at least as diverse as
> any other aspect of programming, and just about any
> style/approach can be made to work great, although some
> with a lot more care and opportunity for error than others.
>
>
>> On Wed, Aug 15, 2012 at 11:44 PM, Boehm, Hans<[address removed]>  wrote:
>
>>> This doesn't mean that synchronization to avoid data races is entirely
>>> free, but only that it's cost doesn't increase, and often decreases with
>>> scale.  Doug may well have run more careful experiments around this.
>
> Right; see above. It's hard to generalize beyond the observation
> that, with sufficiently fine-grained control, sync is rarely the
> main bottleneck, mainly because efficient combinations of immutability,
> publication idioms, CAS, blocking sync, etc become available.
> But that over-reliance on coarse-grained locking is a common
> performance/scalabil­ity problem in Java programs.
>
> -Doug
>
> ____________________­____________________­_______
> Concurrency-interest­ mailing list
> [address removed]
> http://cs.oswego....­

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference, in collaboration with the LJC 12/13 Jun 14

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • Packt Publishing

    A publishing company specializing on specific technologies and solutions

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy