[concurrency-interest] Re: Question about Hashtable and ConcurrentHashMap.

Paul Wagland paul@kungfoocoder.org
Thu, 7 Oct 2004 08:58:40 +0200


This message is in MIME format and has been PGP signed.

--=_513whgh6tkw0
Content-Type: text/plain; charset=UTF-8; format="flowed"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

On Thu 07 Oct 2004 08:22:52 AM CEST, Joe Bowbeer wrote:

> I successfully waged a campaign against a drop-in replacement.
>
> My campaign was based on fear.
>
> Fear that replacing "synchronized" Hashtable with ConcurrentHashMap would
> break the 1000's of synchronized Hashtable subclasses in subtle ways.

This I think is a valid fear, people are allowed to rely on documented
behaviours :-)

[--- snip of examples ---]

However, the following I am not sure is a reason... Surely though the 
concurrent
classes would not break the following? I mean, one can argue about the 
style if
desired, but replacing Hashtable with ConcurrentHashMap should not break this
code? Or is there something really fundamental that I am missing?

> Also, it's not uncommon for Java programmers to "synchronize" the hashtable
> object when they want to temp. lock the hashtable:
>
>   synchronized (hashtable) {
>     hashtable.get ...
>     hashtable.put ...
>     // etc
>   }
>
> A lot of this code was written by early adopters (gotta love 'em), and a lot
> of this code is still running today.

Cheers,
Paul

> ----- Original Message -----
> From: "Martin Buchholz" <Martin.Buchholz@Sun.COM>
> To: <Bino.George@Sun.COM>; <concurrency-interest@altair.cs.oswego.edu>
> Cc: <tl-dev@Sun.COM>; <Kenneth.Russell@Sun.COM>; <Jeannette.Hung@Sun.COM>
> Sent: Wednesday, October 06, 2004 10:16 PM
> Subject: [concurrency-interest] Re: Question about Hashtable and
> ConcurrentHashMap.
>
>
> Bino, I've taken the liberty of forwarding your question to the
> Experts.
>
> In my opinion... they are not compatible *enough*, and the
> performance advantage is probably only significant when
> concurrency is high.
>
> Martin
>
> Bino George wrote:
>> Hi Folks,
>>           I have been reading that ConcurrentHashMap is compatible
>> with Hashtable and is mush faster than Hashtable. So is there any reason
>> why we could not replace the implementation of Hashtable with that of
>> ConcurrentHashMap ? Obviously there must be a reason why it was not
>> done ? Can you tell me what the reason is ?
>>
>> Thanks,
>> Bino.
>>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest@altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest@altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>



--=_513whgh6tkw0
Content-Type: application/pgp-signature
Content-Description: PGP Digital Signature
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQBBZOkgtch0EvEFvxURAkRgAJ4j9ooAO0VAaKyHBfRi2UidhkgTMgCeMEjJ
RfAW2+mxJEYa6xEIDKUObQU=
=4apa
-----END PGP SIGNATURE-----

--=_513whgh6tkw0--