RE: JavaMemoryModel: Immutablity and Final Fields

From: David Holmes (dholmes@dstc.edu.au)
Date: Mon Feb 26 2001 - 21:17:30 EST


> > I wonder how the overhead of ThreadLocal compares to either
> > a synchronized accessor or a volatile reference. ;-)
>
> It is implemented as a synchronizedMap in Sun's JDK, IIRC.

It's an unsynchronized HashMap as of JDK 1.3. So maybe the overhead is not
that significant.

> Seems to me that you could associate the barrier with an
> instance of the thread object.

Sure - that's what a thread-local is. If you have control over thread
creation then you can use real thread-subclass fields as your thread-locals;
otherwise you need to use ThreadLocal.

David
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:30 EDT