As I'm browsing around the source trying to learn my way around I ran
across the OXFClassLoader class. I didn't make it pass the first method in the source when I ran into the "Double Check Lock" idiom. If your wondering why I'm commenting about it then please read the following two articles about the use of this broken java idiom: http://www-128.ibm.com/developerworks/java/library/j-dcl.html http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html I'd be interested to hear the main developers perspective on this idiom. -Brian -- /* insert witty comment here */ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Brian,
Interesting (although the authors of the second link deserve death for not putting a date on the paper ;-). I didn't have time to read it all, but this is what the first link says: "The issue of the failure of double-checked locking is not due to implementation bugs in JVMs but to the current Java platform memory model. The memory model allows what is known as "out-of-order writes" and is a prime reason why this idiom fails." Now it looks like JSR-133 was meant to address some related issues, and that these articles are pre-JSR-133: http://www.jcp.org/en/jsr/detail?id=133 However I read: "There exist a number of common but dubious coding idioms, such as the double-checked locking idiom, that are proposed to allow threads to communicate without synchronization. Almost all such idioms are invalid under the existing semantics, and are expected to remain invalid under the proposed semantics." So still no luck even with JDK 1.5? But I also found this: http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#dcl This seems to say that using a "volatile" variable, things will work, but then goes on to recommend another, simpler pattern. So I guess the bottom line is that we shouldn't use this pattern without using "volatile" and JDK 1.5, or simply not use this pattern at all! -Erik Brian Weaver wrote: > As I'm browsing around the source trying to learn my way around I ran > across the OXFClassLoader class. I didn't make it pass the first > method in the source when I ran into the "Double Check Lock" idiom. > If your wondering why I'm commenting about it then please read the > following two articles about the use of this broken java idiom: > > http://www-128.ibm.com/developerworks/java/library/j-dcl.html > http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html > > I'd be interested to hear the main developers perspective on this idiom. > > -Brian Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |