commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <>
Subject RE: [Collections] StaticBucketMap not thread safe
Date Tue, 25 Jun 2002 20:21:52 GMT
> What about making the m_buckets volatile?  Wouldn't that
> help?

Unfortunately no, making an array volatile currently only
makes the array reference itself volatile, not the array 
elements.  (There's no way to make the array elements 
volatile in the current JVM).

However, I was wrong.  *Every* access to m_buckets is
synchronized, it's just synchronized on some other object's
monitor.  But that doesn't matter, as threads still have to
go through a memory barrier in order to fetch a Node.

So, false alarm.  That's the second time I posted something
today and immediately realized I shouldn't have.  I just got
back from a four-day vacation, my mind is clearly still at
the beach. :)

There still might be threading issues with making the 
collection views properly follow the Map contract, but then 
again, maybe not.  I'll see what I can do...


> I can tell you this much--if you have to synchronize on
> every access to m_buckets then you lose all advantage of
> BucketMap and you would actually be better off working
> with a synchronized map via Collections.synchronizedMap().
> What will end up happening is essentially the same as
> every access will be synchronized at the same point.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message