[concurrency-interest] RE: Concurrency-interest Digest, Vol 4, Issue 4

Unmesh joshi unmesh_joshi at hotmail.com
Wed May 4 19:14:04 EDT 2005


Thank you for all your replies. With all these,  I guess, I will be able 
convince my tech lead.
I have a question though, about On Demand Holder Idiom. If the constructor 
of Singleton is throwing exception, we will not be able to use it?
public class Cache {


  private static class OnDemandHelher {
       static Cache instance = new Cache(); ///
  }

  private Cache() throws InitializationException {
    //load data...
  }

}

Thanks,
Unmesh

>From: concurrency-interest-request at cs.oswego.edu
>Reply-To: concurrency-interest at cs.oswego.edu
>To: concurrency-interest at altair.cs.oswego.edu
>Subject: Concurrency-interest Digest, Vol 4, Issue 4
>Date: Wed, 4 May 2005 07:52:49 -0400 (EDT)
>
>Send Concurrency-interest mailing list submissions to
>	concurrency-interest at altair.cs.oswego.edu
>
>To subscribe or unsubscribe via the World Wide Web, visit
>	http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>or, via email, send a message with subject or body 'help' to
>	concurrency-interest-request at altair.cs.oswego.edu
>
>You can reach the person managing the list at
>	concurrency-interest-owner at altair.cs.oswego.edu
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Concurrency-interest digest..."
>
>
>Today's Topics:
>
>    1. Re: How seriously should we take broken	doublechecked idiom
>       (Dawid Kurzyniec)
>    2. Re: How seriously should we take broken	doublechecked idiom
>       (serge masse)
>    3. Re: How seriously should we take	brokendoublechecked idiom
>       (Dawid Kurzyniec)
>    4. Re: How seriously should we	takebrokendoublechecked idiom
>       (Dawid Kurzyniec)
>    5. Re: How seriously should we	takebrokendoublechecked idiom
>       (serge masse)
>    6. Re: How seriously should	we	takebrokendoublechecked idiom
>       (Jeremy Manson)
>    7. Java 5 memory model - a nice lit roundup	from Jeremy (serge masse)
>    8. RE: How seriously should we take	brokendoublechecked idiom
>       (Boehm, Hans)
>    9. Re: How seriously should we	takebrokendoublechecked idiom
>       (Dawid Kurzyniec)
>   10. Re: reusing threads and thread local state
>       (Osvaldo Pinali Doederlein)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Tue, 03 May 2005 14:45:47 -0400
>From: Dawid Kurzyniec <dawidk at mathcs.emory.edu>
>Subject: Re: [concurrency-interest] How seriously should we take
>	broken	doublechecked idiom
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <4277C6DB.8060202 at mathcs.emory.edu>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Bill Pugh wrote:
>
> > Please tell me what project you work on so I can avoid it, or what
> > company you work for so I can short your stock.
> >
> > Like others, I am appalled at your tech lead's attitude towards
> > software reliability.
> >
> > There is essentially no cost to performing thread-safe lazy
> > initialization in a correct way, and several
> > possible correct ways to accomplish it.
> >
>Not trying to argue with what you guys say and suggest as alternatives,
>I think you might be a bit too harsh in reacting to the question. After
>all, "double checked locking" idiom was once blessed and recommended,
>and, correct me if I am wrong, but I think I have seen several uses of
>it in core Java classes. It will take time and patience to educate
>people that it is not correct; also, I can understand that people may
>count that the idiom will work on SUN JVMs even though not guaranteed by
>the spec, just because SUN once was using it in its own code. Even
>though this expectation may be unjustified, especially on SMP machines,
>still - educating (and especially un-educating) people always takes time
>and patience. Also, after all, the fact that this question was asked on
>this forum suggests that the company might actually be quite sane :)
>
>Just my 2c,
>Regards,
>Dawid Kurzyniec
>
>
>
>------------------------------
>
>Message: 2
>Date: Tue, 3 May 2005 13:13:36 -0700 (PDT)
>From: serge masse <sergemasse1 at yahoo.com>
>Subject: Re: [concurrency-interest] How seriously should we take
>	broken	doublechecked idiom
>To: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <20050503201336.44076.qmail at web51404.mail.yahoo.com>
>Content-Type: text/plain; charset=us-ascii
>
>I agree with Dawid.
>
>Finally a person on this thread with .edu in his
>address who appears to be average iq or above.
>
>serge
>
>--- Dawid Kurzyniec <dawidk at mathcs.emory.edu> wrote:
> > Bill Pugh wrote:
> >
> > > Please tell me what project you work on so I can
> > avoid it, or what
> > > company you work for so I can short your stock.
> > >
> > > Like others, I am appalled at your tech lead's
> > attitude towards
> > > software reliability.
> > >
> > > There is essentially no cost to performing
> > thread-safe lazy
> > > initialization in a correct way, and several
> > > possible correct ways to accomplish it.
> > >
> > Not trying to argue with what you guys say and
> > suggest as alternatives,
> > I think you might be a bit too harsh in reacting to
> > the question. After
> > all, "double checked locking" idiom was once blessed
> > and recommended,
> > and, correct me if I am wrong, but I think I have
> > seen several uses of
> > it in core Java classes. It will take time and
> > patience to educate
> > people that it is not correct; also, I can
> > understand that people may
> > count that the idiom will work on SUN JVMs even
> > though not guaranteed by
> > the spec, just because SUN once was using it in its
> > own code. Even
> > though this expectation may be unjustified,
> > especially on SMP machines,
> > still - educating (and especially un-educating)
> > people always takes time
> > and patience. Also, after all, the fact that this
> > question was asked on
> > this forum suggests that the company might actually
> > be quite sane :)
> >
> > Just my 2c,
> > Regards,
> > Dawid Kurzyniec
> >
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> >
>http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
>
>
>------------------------------
>
>Message: 3
>Date: Tue, 03 May 2005 16:30:24 -0400
>From: Dawid Kurzyniec <dawidk at mathcs.emory.edu>
>Subject: Re: [concurrency-interest] How seriously should we take
>	brokendoublechecked idiom
>To: serge masse <sergemasse1 at yahoo.com>
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <4277DF60.9070105 at mathcs.emory.edu>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>serge masse wrote:
>
> >I agree with Dawid.
> >
> >Finally a person on this thread with .edu in his
> >address who appears to be average iq or above.
> >
> >
> >
>Oops... I hope you know that people who answered before me on this
>thread are probably the most qualified in the world to address this sort
>of questions, and I wouldn't doubt their IQ:
>
>http://www.cs.umd.edu/~pugh/java/
>http://www.briangoetz.com/pubs.html
>http://www.jaoo.org/jaoo2000/conference/speakers/holmes.html
>
>Regards,
>Dawid Kurzyniec
>
>
>
>------------------------------
>
>Message: 4
>Date: Tue, 03 May 2005 16:41:05 -0400
>From: Dawid Kurzyniec <dawidk at mathcs.emory.edu>
>Subject: Re: [concurrency-interest] How seriously should we
>	takebrokendoublechecked idiom
>To: serge masse <sergemasse1 at yahoo.com>
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <4277E1E1.4040208 at mathcs.emory.edu>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Dawid Kurzyniec wrote:
>
> > serge masse wrote:
> >
> >> I agree with Dawid.
> >> Finally a person on this thread with .edu in his
> >> address who appears to be average iq or above.
> >>
> >>
> >>
> > Oops... I hope you know that people who answered before me on this
> > thread are probably the most qualified in the world to address this
> > sort of questions, and I wouldn't doubt their IQ:
> >
> > http://www.cs.umd.edu/~pugh/java/
> > http://www.briangoetz.com/pubs.html
> > http://www.jaoo.org/jaoo2000/conference/speakers/holmes.html
> >
>I forgot one more :)
>
>http://www.cs.umd.edu/users/jmanson/java/thesis.pdf
>
>Regards,
>Dawid
>
>
>
>------------------------------
>
>Message: 5
>Date: Tue, 3 May 2005 13:46:26 -0700 (PDT)
>From: serge masse <sergemasse1 at yahoo.com>
>Subject: Re: [concurrency-interest] How seriously should we
>	takebrokendoublechecked idiom
>To: Dawid Kurzyniec <dawidk at mathcs.emory.edu>
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <20050503204626.3452.qmail at web51405.mail.yahoo.com>
>Content-Type: text/plain; charset=us-ascii
>
>Thanks Dawid,
>I was not aware of this thesis. Will read it, or try
>to. I downloaded it.
>
>serge
>
>--- Dawid Kurzyniec <dawidk at mathcs.emory.edu> wrote:
> > Dawid Kurzyniec wrote:
> >
> > > serge masse wrote:
> > >
> > >> I agree with Dawid.
> > >> Finally a person on this thread with .edu in his
> > >> address who appears to be average iq or above.
> > >>
> > >>
> > >>
> > > Oops... I hope you know that people who answered
> > before me on this
> > > thread are probably the most qualified in the
> > world to address this
> > > sort of questions, and I wouldn't doubt their IQ:
> > >
> > > http://www.cs.umd.edu/~pugh/java/
> > > http://www.briangoetz.com/pubs.html
> > >
> >
>http://www.jaoo.org/jaoo2000/conference/speakers/holmes.html
> > >
> > I forgot one more :)
> >
> > http://www.cs.umd.edu/users/jmanson/java/thesis.pdf
> >
> > Regards,
> > Dawid
> >
> >
>
>
>------------------------------
>
>Message: 6
>Date: Tue, 03 May 2005 16:18:51 -0500
>From: Jeremy Manson <jmanson at cs.purdue.edu>
>Subject: Re: [concurrency-interest] How seriously should	we
>	takebrokendoublechecked idiom
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <4277EABB.6080108 at cs.purdue.edu>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>serge masse wrote:
> > Thanks Dawid,
> > I was not aware of this thesis. Will read it, or try
> > to. I downloaded it.
> >
> > serge
> >
>
>Well, I suppose that at this point, I might as well chime in with a
>reading list.  I'm pretty sure that although these things have been
>announced on this list, there has never been a roundup.
>
>Depending on your level of interest in the memory model (and depending
>on your level of expertise), you may be better off starting with one of
>Brian's articles:
>
>http://www-106.ibm.com/developerworks/java/library/j-jtp02244.html
>http://www-106.ibm.com/developerworks/java/library/j-jtp03304/
>
>Or the FAQ that he and I wrote:
>
>http://www.cs.umd.edu/users/pugh/java/memoryModel/jsr-133-faq.html
>
>For a more technical / academic version of this stuff, the paper that
>Bill, Sarita Adve and I wrote for this year's POPL might be a good bet.
>
>http://www.cs.umd.edu/~jmanson/java/popl05.pdf
>
>JSR-133 itself is also a good place to go:
>
>http://www.jcp.org/en/jsr/detail?id=133
>
>Mind you, I'm not trying to dissuade anyone from reading my
>dissertation.  I think (with no modesty whatsoever) I did a pretty good
>job of laying out the issues.  It is the only place to go (currently)
>for a full explanation of all our decisions.  But it may be more than a
>lot of people want to plow through.
>
>					Jeremy
>
>
>------------------------------
>
>Message: 7
>Date: Tue, 3 May 2005 15:36:15 -0700 (PDT)
>From: serge masse <sergemasse1 at yahoo.com>
>Subject: [concurrency-interest] Java 5 memory model - a nice lit
>	roundup	from Jeremy
>To: Jeremy Manson <jmanson at cs.purdue.edu>
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID: <20050503223616.34818.qmail at web51409.mail.yahoo.com>
>Content-Type: text/plain; charset=us-ascii
>
>Great literature round up Jeremy. Thanks.
>
>As for your dissertation being *more than a
>lot of people want to plow through*, I had a quick
>look and it looks like the prose is as easy to read as
>a novel (maybe a Le Carre) compared to the
>specifications, which I read last year. So I do
>recommend it highly for any serious Java dev.
>
>serge
>
>--- Jeremy Manson <jmanson at cs.purdue.edu> wrote:
> > serge masse wrote:
> > > Thanks Dawid,
> > > I was not aware of this thesis. Will read it, or
> > try
> > > to. I downloaded it.
> > >
> > > serge
> > >
> >
> > Well, I suppose that at this point, I might as well
> > chime in with a
> > reading list.  I'm pretty sure that although these
> > things have been
> > announced on this list, there has never been a
> > roundup.
> >
> > Depending on your level of interest in the memory
> > model (and depending
> > on your level of expertise), you may be better off
> > starting with one of
> > Brian's articles:
> >
> >
>http://www-106.ibm.com/developerworks/java/library/j-jtp02244.html
> >
>http://www-106.ibm.com/developerworks/java/library/j-jtp03304/
> >
> > Or the FAQ that he and I wrote:
> >
> >
>http://www.cs.umd.edu/users/pugh/java/memoryModel/jsr-133-faq.html
> >
> > For a more technical / academic version of this
> > stuff, the paper that
> > Bill, Sarita Adve and I wrote for this year's POPL
> > might be a good bet.
> >
> > http://www.cs.umd.edu/~jmanson/java/popl05.pdf
> >
> > JSR-133 itself is also a good place to go:
> >
> > http://www.jcp.org/en/jsr/detail?id=133
> >
> > Mind you, I'm not trying to dissuade anyone from
> > reading my
> > dissertation.  I think (with no modesty whatsoever)
> > I did a pretty good
> > job of laying out the issues.  It is the only place
> > to go (currently)
> > for a full explanation of all our decisions.  But it
> > may be more than a
> > lot of people want to plow through.
> >
> > 					Jeremy
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> >
>http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
>
>
>------------------------------
>
>Message: 8
>Date: Tue, 3 May 2005 14:27:38 -0700
>From: "Boehm, Hans" <hans.boehm at hp.com>
>Subject: RE: [concurrency-interest] How seriously should we take
>	brokendoublechecked idiom
>To: "Dawid Kurzyniec" <dawidk at mathcs.emory.edu>
>Cc: concurrency-interest at altair.cs.oswego.edu
>Message-ID:
>	<65953E8166311641A685BDF71D8658262B6F12 at cacexc12.americas.cpqcorp.net>
>Content-Type: text/plain;	charset="us-ascii"
>
>A lot of my concern in ignoring such correctness issues
>would be that once you go down that road at all, you
>no longer know whether a given failure is expected or not,
>making it much harder to diagnose even the unrelated ones.
>When you see a highly intermittent failure, it's hard enough
>to try to reason backwards about what might have caused it,
>without also considering the impact of intentional
>"low probability" bugs.
>
>It's much harder to reason about failure "probabilities"
>than to argue that something is correct.  Especially when
>these aren't real probabilities.  Something that fails 1
>in a zillion times now during testing, may fail every other
>time next time somebody releases a new OS kernel with a
>different thread scheduler, or when someone releases a
>new machine with different timing characteristics.
>
>You really don't want to go there intentionally.
>Concurrent systems tend to have more than enough of these
>problems without intentionally adding more.  Especially
>when it's cheap to avoid.
>
>Once you stop aiming for 100% correctness, things get very
>complicated.
>
>As you suggest, on hardware with weak memory ordering, there
>is no practical way for a JVM to ensure that double-checked
>locking works without the volatile declaration.  VMs
>will not support it for backward compatibility because they
>can't, at least not on platforms like PowerPC or Itanium.
>
>Hans
>
> > -----Original Message-----
> > From: concurrency-interest-bounces at cs.oswego.edu
> > [mailto:concurrency-interest-bounces at cs.oswego.edu] On Behalf
> > Of Dawid Kurzyniec
> > Sent: Tuesday, May 03, 2005 11:46 AM
> > Cc: concurrency-interest at altair.cs.oswego.edu
> > Subject: Re: [concurrency-interest] How seriously should we
> > take brokendoublechecked idiom
> >
> >
> > Bill Pugh wrote:
> >
> > > Please tell me what project you work on so I can avoid it, or what
> > > company you work for so I can short your stock.
> > >
> > > Like others, I am appalled at your tech lead's attitude towards
> > > software reliability.
> > >
> > > There is essentially no cost to performing thread-safe lazy
> > > initialization in a correct way, and several
> > > possible correct ways to accomplish it.
> > >
> > Not trying to argue with what you guys say and suggest as
> > alternatives,
> > I think you might be a bit too harsh in reacting to the
> > question. After
> > all, "double checked locking" idiom was once blessed and recommended,
> > and, correct me if I am wrong, but I think I have seen
> > several uses of
> > it in core Java classes. It will take time and patience to educate
> > people that it is not correct; also, I can understand that people may
> > count that the idiom will work on SUN JVMs even though not
> > guaranteed by
> > the spec, just because SUN once was using it in its own code. Even
> > though this expectation may be unjustified, especially on SMP
> > machines,
> > still - educating (and especially un-educating) people always
> > takes time
> > and patience. Also, after all, the fact that this question
> > was asked on
> > this forum suggests that the company might actually be quite sane :)
> >
> > Just my 2c,
> > Regards,
> > Dawid Kurzyniec
> >
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
>
>
>
>------------------------------
>
>Message: 9
>Date: Wed, 04 May 2005 01:09:28 -0400
>From: Dawid Kurzyniec <dawidk at mathcs.emory.edu>
>Subject: Re: [concurrency-interest] How seriously should we
>	takebrokendoublechecked idiom
>To: "Boehm, Hans" <hans.boehm at hp.com>,
>	concurrency-interest at altair.cs.oswego.edu
>Message-ID: <42785908.3050404 at mathcs.emory.edu>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Boehm, Hans wrote:
>
> >A lot of my concern in ignoring such correctness issues (...)
> >
> >
>Just to clarify: I never meant to imply that it is OK to use DCL. In
>postings preceding mine, and in yours, it was clearly demonstrated that
>there is no technical reason to use it. I only commented the form, not
>the technical merit.
>
>Cheers,
>Dawid
>
>
>
>
>------------------------------
>
>Message: 10
>Date: Wed, 04 May 2005 08:30:46 -0300
>From: Osvaldo Pinali Doederlein <osvaldo at visionnaire.com.br>
>Subject: Re: [concurrency-interest] reusing threads and thread local
>	state
>To: Gregg Wonderly <gergg at cox.net>
>Cc: larryr at saturn.sdsu.edu, Pete Soper <Pete.Soper at sun.com>,
>	concurrency-interest at altair.cs.oswego.edu
>Message-ID: <4278B266.3050405 at visionnaire.com.br>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Hi,
>
>Gregg Wonderly wrote:
> > Larry Riedel wrote:
> > I don't use threadlocals myself because it is just as easy to use a
> > Hashtable<Thread,Hashtable<String,?>> via a static factory which I can
> > control access to and manage clearing etc on my own.
>
>Humm... I always assumed that ThreadLocal is more efficient and it
>should play better with thread deaths.  I see in the source that it's
>indeed highly customized an optimized, using its own implementation of
>Map, private variables from Thread etc.  Not to mention quoting Donald
>Knuth's algorithms, so I feel better using it ;)
>
>A+
>Osvaldo
>
>--
>-----------------------------------------------------------------------
>Osvaldo Pinali Doederlein                   Visionnaire Informática S/A
>osvaldo at visionnaire.com.br                http://www.visionnaire.com.br
>Arquiteto de Tecnologia                          +55 (41) 337-1000 #223
>
>
>
>------------------------------
>
>_______________________________________________
>Concurrency-interest mailing list
>Concurrency-interest at altair.cs.oswego.edu
>http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
>End of Concurrency-interest Digest, Vol 4, Issue 4
>**************************************************

_________________________________________________________________
Bought a New Cellphone? 
http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-265?ck=Register Sell your 
old one for a Great Price in eBay!



More information about the Concurrency-interest mailing list