[concurrency-interest] Class variables and concurrency

Dawid Kurzyniec dawidk at mathcs.emory.edu
Sat Nov 5 18:51:29 EST 2005

Luís Matta wrote:

> OK, so I got of my lazy butt and I have created a simple test attached 
> below and the bug _*DID*_ manifest itself.
> Any comments on it?.
I may have misunderstood your first post. Were you asking if the bug in 
the *original* code will manifest itself? Well, you've just found out 
yourself that yes, very much so. Now, I was responding to your fix: for 
it to be 100% correct, you need that "final". To my understanding 
(experts correct me if I'm wrong), you may otherwise see this field 
uninitialized (i.e. null) in some threads. The simplest way to avoid 
worrying about it is to use that "final".

Because of the race condition, the code you were testing is 
undeterministic, which means in practice that it depends on so many 
things that differences between JVMs come at no surprise.


More information about the Concurrency-interest mailing list