Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 6578 invoked from network); 10 Feb 2005 13:37:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Feb 2005 13:37:49 -0000 Received: (qmail 17890 invoked by uid 500); 10 Feb 2005 13:37:46 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 17459 invoked by uid 500); 10 Feb 2005 13:37:44 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 17446 invoked by uid 99); 10 Feb 2005 13:37:44 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from dns.pace2020.com (HELO wahoo.pace2020.com) (65.196.130.133) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 10 Feb 2005 05:37:42 -0800 Received: from fotap.org ([63.211.45.38] helo=[192.168.42.4]) by wahoo.pace2020.com with asmtp (Exim 3.35 #1 (Debian)) id 1CzEVn-0006gk-00 for ; Thu, 10 Feb 2005 08:37:39 -0500 Mime-Version: 1.0 (Apple Message framework v619) In-Reply-To: References: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: Content-Transfer-Encoding: quoted-printable X-Image-Url: http://fotap.org/~osi/mail/peter.royal@pobox.com From: peter royal Subject: Re: concurrency and starting a synchronized block Date: Thu, 10 Feb 2005 08:37:37 -0500 To: "Jakarta Commons Developers List" X-Mailer: Apple Mail (2.619) X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Feb 10, 2005, at 8:20 AM, J=F6rg Schaible wrote: > en get() twice: > > Object o =3D map.get(key); > if (o =3D=3D null) { > synchronized(map) { > o =3D map.get(key); > if (o =3D=3D null) { > map.put(key,new Object()); > } > } > } > > since 99% of the time it will not enter the block, the second lookup=20= > does not matter ... Is that still enough to not be double-checked locking (which is broken=20= in java..) http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html -pete= --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org