river-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patricia Shanahan <p...@acm.org>
Subject Re: MarshalledServiceItem
Date Tue, 08 Feb 2011 17:51:23 GMT
Gregg Wonderly wrote:
> On 2/8/2011 10:51 AM, Patricia Shanahan wrote:
>> There are some negatives to using CHM compared to wrapping a HashMap in a
>> synchronized map. It is easy to write methods for compound operations 
>> such as
>> removing a key-value pair if, and only if, some other key is present.
> 
> Yes, this is true.  If we do need some compound operations, then it 
> would be necessary to add a lock to synchronize on, and then everything 
> else referencing the structure would need to be synchronized since CHM 
> uses internal locking which does not involve synchronized(this).

Or switch implementations if there is a problem with the initial choice. 
If the code uses the Map interface, implemented by both CHM and a 
synchronized map wrapping a HashMap, it should just be a matter of 
changing the initialization expression.

Patricia

Mime
View raw message