Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: multithreaded cache? Date: Sat, 19 May 2012 07:09:31 -0400 Organization: A noiseless patient Spider Lines: 24 Message-ID: References: <4fb69812$0$6849$e4fe514c@news2.news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 19 May 2012 11:09:35 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="03ebLEozl+tXCe7JS60Feg"; logging-data="12325"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lnYPfFwfR8CFDFPW82tNO" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: Cancel-Lock: sha1:WvLEusY1Xm6LM5RS2719nEtEDgA= Xref: csiph.com comp.lang.java.programmer:14641 On 5/19/2012 1:15 AM, Daniel Pitts wrote: > On 5/18/12 3:31 PM, Eric Sosman wrote: >> On 5/18/2012 5:45 PM, Robert Klemme wrote: >>>[...] >>> You didn't show it here, did you? I can's seem to find it in the thread. >>> Note that CHM does also do synchronization. I am not sure from your >>> statement what exact locking scheme you apply. There does seem to be one >>> difference though: I my version the second lock goes away after the >>> value has been computed so there is only the sync of CHM left. >> >> It seems to me that if N threads query the same key at about >> the same time, they may all miss the map and go off to perform >> the slow computation. > Nope, they will all create a "Reference" object that *can* perform the > calculation, however because the method uses "putIfAbsent", only the > first calculating "Reference" object is actually ever used. > [...] Re-reading, I think you're right. "Never mind," as Emily Litella used to say. -- Eric Sosman esosman@ieee-dot-org.invalid