[prev in list] [next in list] [prev in thread] [next in thread]
List: mondrian
Subject: [Mondrian] Double-checked locking
From: "Julian Hyde" <jhyde () pentaho ! com>
Date: 2008-11-23 2:28:42
Message-ID: 4612FE0F390B4395B9CB0B3C0A98D66E () mackerel
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Most of you probably know that double-checked locking is unsound in Java.
But it bears repeating from time to time, because every Java programmer
writing threadsafe code needs to know it. Please read and digest.
http://en.wikipedia.org/wiki/Double-checked_locking
According to this article you can use the 'volatile' keyword from JDK 1.5
onwards and eliminate the problem. However, I would stick with the
'synchronize everything' approach unless you have a good reason to do
otherwise.
Julian
[Attachment #5 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6001.18148" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2>Most of you probably know that double-checked locking is unsound in Java.
But it bears repeating from time to time, because every Java programmer writing
threadsafe code needs to know it. Please read and digest.</FONT></SPAN></DIV>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2><A
href="http://en.wikipedia.org/wiki/Double-checked_locking">http://en.wikipedia.org/wiki/Double-checked_locking</A></FONT></SPAN></DIV>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2>According to this article you can use the 'volatile' keyword from JDK 1.5
onwards and eliminate the problem. However, I would stick with the 'synchronize
everything' approach unless you have a good reason to do
otherwise.</FONT></SPAN></DIV>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=345432101-23112008><FONT face="Lucida Sans" color=#000080
size=2>Julian</FONT></SPAN></DIV></BODY></HTML>
_______________________________________________
Mondrian mailing list
Mondrian@pentaho.org
http://lists.pentaho.org/mailman/listinfo/mondrian
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic