Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A76C7CE96 for ; Fri, 1 Jun 2012 16:18:00 +0000 (UTC) Received: (qmail 15569 invoked by uid 500); 1 Jun 2012 16:17:57 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 15516 invoked by uid 500); 1 Jun 2012 16:17:57 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 15501 invoked by uid 99); 1 Jun 2012 16:17:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2012 16:17:57 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [76.96.62.32] (HELO qmta03.westchester.pa.mail.comcast.net) (76.96.62.32) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2012 16:17:49 +0000 Received: from omta15.westchester.pa.mail.comcast.net ([76.96.62.87]) by qmta03.westchester.pa.mail.comcast.net with comcast id GzsC1j0081swQuc534HUvH; Fri, 01 Jun 2012 16:17:28 +0000 Received: from Christophers-MacBook-Pro.local ([69.143.109.145]) by omta15.westchester.pa.mail.comcast.net with comcast id H4HU1j00638FjT13b4HUZh; Fri, 01 Jun 2012 16:17:28 +0000 Message-ID: <4FC8EB18.4040106@christopherschultz.net> Date: Fri, 01 Jun 2012 12:17:28 -0400 From: Christopher Schultz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Question about resetting datasources and changes to the BasicDataSource.close() method References: <30A8B1E10B6694429B87D8D9FBF45C8E024EB9EC8261@Exchange02.rainhail.com> <30A8B1E10B6694429B87D8D9FBF45C8E024EB9EC8270@Exchange02.rainhail.com> <4FC7C5F2.2000007@christopherschultz.net> <30A8B1E10B6694429B87D8D9FBF45C8E024EB9EC828A@Exchange02.rainhail.com> <4FC7EF38.2090006@christopherschultz.net> <30A8B1E10B6694429B87D8D9FBF45C8E024EB9EC8298@Exchange02.rainhail.com> In-Reply-To: <30A8B1E10B6694429B87D8D9FBF45C8E024EB9EC8298@Exchange02.rainhail.com> X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Brooke, On 6/1/12 11:54 AM, Hedrick, Brooke - 43 wrote: >> -----Original Message----- From: Christopher Schultz >> [mailto:chris@christopherschultz.net] Sent: Thursday, May 31, >> 2012 5:23 PM > > That's what I will submit to commons-dbcp, then. > >> On the one hand, synchronizing these methods should not be >> necessary because Java boolean values are defined to be 32-bit >> integers which feature atomic assignment (that is, no thread ever >> sees only 8-bits of the 32-bit value being assigned and 24-bits >> of the old value). On the other hand, threads are allowed to keep >> cached copies of certain data under certain conditions. Using the >> keyword 'volatile' /should/, in recent JVMs, make the use of >> 'synchronized' completely unnecessary, while older JVMs may even >> ignore 'volatile' making 'synchronized' mandatory. Use of >> 'synchronized' is the safest bet because it definitely causes a >> 'memory barrier' to be crossed in any version of JVM: that means >> that the thread is required to synchronize (perhaps a bad choice >> of words) its cache with main memory which means that all >> variables get the latest copies of the "real" data. > > Yep. That was my point too. What does it really matter anyway > whether you are able to lock "this" in a getter. When you ask > for the value, you are just asking for what is current. You have > to protect yourself from non-initialized/null in any case. It just > adds some unnecessary overhead ( to the JVM and brain ) to > synchronize your getter when it doesn't mutate the data - unless I > am missing something. Locking "this" makes sure that the thread's local copy of whatever-you-are-getting is updated properly and not stale-cached. If you synchronize the setter, it is a very good idea to synchronize the getter too. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/I6xcACgkQ9CaO5/Lv0PA87wCeLBo6OzS2H/oEq9pEEduhYNnV xFEAn1sPEI8bUvvC2HSQKKb9Z5tpMQ4b =vMfh -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org