On Fri, Jul 8, 2011 at 7:23 PM, Dan Muresan <danmbox(a)gmail.com> wrote:
(
http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html):
...
The only thing that volatile accomplishes is to slow down
properly-synchronized programs. volatile is for signal handlers and
interrupt handlers, not for threading.
...
This reordering cannot be prevented without proper synchronization. So
my advice to anyone considering this would be to drop volatile and do
proper synchronization at the application level (i.e. semaphores,
since it has to work in real time).
+1
volatile is not the droid you're looking for.
- Dan