On Fri, May 11, 2012 at 6:33 PM, Howard Lewis Ship <hls...@gmail.com> wrote:
> That's a common mistake. Although I've heard that future JDK/JVM may > address this common case, it is not valid to read a shared variable > outside a synchronized block, even to check for null-ness. This was a > common mistake propagated in books and blogs in the early 2000's. > I believe that Java Memory Model was changed in Java 5 to fix this problem (JSR-133). You still need to mark a shared variable 'volatile', but checking for null-ness should be OK. - Cezary