[concurrency-interest] concurrency errors in java.lang.Throwable

Gregg Wonderly gergg at cox.net
Thu Aug 3 13:36:53 EDT 2006

Rémi Forax wrote:
> I've a test case that shows the bug :


> "bang !" is never (at least 15min :) printed with the server VM.

Right...  Because you are publishing without synchronization, the initCause() 
call's action of setting the field in one thread is not guarenteed to be visible 
in another threads read of that field.

On my laptop (dual core Xeon), it does become visible.  Perhaps because of the 
rate of garbage generation (new Throwable()), the GC activities are driving the 

As David said, "Only trouble is today it is Throwable tomorrow, its ...".  There 
are all kinds of opportunities for threads to forget to synchronize 
communications/publishing of values between threads.  That's the education issue.

Gregg Wonderly

More information about the Concurrency-interest mailing list