Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0B52C1DCCF96 for ; Sun, 6 May 2012 17:18:32 -0300 (ADT) Received: from mail.dewire.com ([83.140.172.130] helo=dewire.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SR7uX-0002BJ-Rj for pgsql-jdbc@postgresql.org; Sun, 06 May 2012 20:18:31 +0000 Received: from localhost (localhost [127.0.0.1]) by dewire.com (Postfix) with ESMTP id 765308007B2; Sun, 6 May 2012 22:18:17 +0200 (CEST) X-Virus-Scanned: by amavisd-new at dewire.com Received: from dewire.com ([127.0.0.1]) by localhost (torino.dewire.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uQ+h0184cJPN; Sun, 6 May 2012 22:18:11 +0200 (CEST) Received: from Robin-Rosenbergs-MacBook-Pro.local (unknown [10.9.0.5]) by dewire.com (Postfix) with ESMTP id DC0A38003FC; Sun, 6 May 2012 22:18:10 +0200 (CEST) Message-ID: <4FA6DC82.2040505@dewire.com> Date: Sun, 06 May 2012 22:18:10 +0200 From: Robin Rosenberg User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120425 Thunderbird/13.0 MIME-Version: 1.0 To: dmp Cc: pgsql-jdbc@postgresql.org Subject: Re: Cleanup patch: Change from Vector/Hashtable to ArrayList/HashMap References: <4FA6BD06.4060308@ttc-cmc.net> In-Reply-To: <4FA6BD06.4060308@ttc-cmc.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/14 X-Sequence-Number: 22914 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