The best way to avoid the double checke locking issue is just not to use it.
Before trying to implement 'double checked locking' right, you have to understand the purpose. The goal was to reduce synchronized access to achieve more performance. (Did you have another rationale ?) In most cases it's just enough to remove the outer if. Also look at: http://www.javaworld.com/javaworld/jw-11-2001/jw-1116-dcl.html (This article also states that ThreadLocal works even slower before JDK 1.4) > -----Original Message----- > From: Jacob Kjome [mailto:hoju@;visi.com] > Sent: Tuesday, October 29, 2002 5:12 AM > To: Tomcat Users List > Cc: Craig R. McClanahan > Subject: Re[2]: DBCP speed of lookup -vs- stored reference to > Datasource? > > I was just making an attempt to avoid the > Double-Checked Locking issue and the article > http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html > under the title "Fixing Double-Checked Locking > using Thread Local Storage" provided an issue > that they said worked. Maybe you could provide > an example showing me what you would do to create > a proper static singleton that doesn't suffer > from the Double-Checked Locking issue without > resorting to the ThreadLocal solution? > -- To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>
