From: | Robin Rosenberg <robin(dot)rosenberg(at)dewire(dot)com> |
---|---|
To: | dmp <danap(at)ttc-cmc(dot)net> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Cleanup patch: Change from Vector/Hashtable to ArrayList/HashMap |
Date: | 2012-05-06 19:59:29 |
Message-ID: | 4FA6D821.5050701@dewire.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
dmp skrev 2012-05-06 20.03:
> Mikko Tiihonen wrote:
> > Hi,
> >
> > Here are two small cleanup patches.
> >
> > First one replaces all Vector references with List (usage) and ArrayList
> > (creation).
> > Second replaces all Hashtable references with Map (usage) and HashMap
> > (creation).
> >
> > Reasons:
> > * Theoretically faster since the ArrayList/HashMap are not synchronized
> > * Using interfaces makes changing of List/Map implementations easier at
> > later time
> > * Vector/Hashtable were deprecated already in Java 1.2
>
> My JDK 6 documentation gives no indication that either Vector or Hashtable
> as being deprecated. Rather them being retrofitted into the Collectionss
> Framework at 1.2. The main difference being that as you said they are
> synchronized, which a developer may wish to have for that type of data
> structure.
They are not deprecated in the "this might go away" sense, but it was discovered
that having self-synchronized collection classes rarely is enough to provide
thread safety, rather synchronization usually has to be handled in a larger
scope than the individual method call. Therefore, if you think Vector makes
your code thread-safe, you need to think again. Even if works it usually a
very expensive way of accomplishing the goal.
-- robin
From | Date | Subject | |
---|---|---|---|
Next Message | Robin Rosenberg | 2012-05-06 20:18:10 | Re: Cleanup patch: Change from Vector/Hashtable to ArrayList/HashMap |
Previous Message | henk de wit | 2012-05-06 19:22:48 | Re: Cleanup patch: Change from Vector/Hashtable to ArrayList/HashMap |