Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: unchecked conversion warning. Date: Sat, 16 Jun 2012 15:17:24 +0200 Lines: 31 Message-ID: References: <3s7cs7hd18l0ffci55ns0286n4lc4cutlu@4ax.com> <265ea956-a3ed-4e76-8fc9-9ce9728f6b37@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 0oj4MJAvsRNscFEAcXbhXAtXLDEYRj/gVuICPdTRtS/I5uTXai8D2FPYS+0yelo/I= Cancel-Lock: sha1:ElYhPXFmEI6rtw74VlFpx70n0G0= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:15331 On 11.06.2012 09:06, Patricia Shanahan wrote: > The documentation, > http://docs.oracle.com/javase/7/docs/api/java/util/Vector.html, says "If > a thread-safe implementation is not needed, it is recommended to use > ArrayList in place of Vector." which implies that Vector might be a > reasonable choice if thread safety is needed. > > Personally, I prefer to use ArrayList as base, and wrap using > Collections.synchronizedCollection, but that is not mandatory. I totally agree. Btw, there is one interesting detail: JavaDoc of Collections.synchronizedList() and the other synchronized*() methods explicitly state that the mutex used for synchronizing is that of the returned object: http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedList%28java.util.List%29 No such statement is done about Vector. So while the source code of Vector tells us that the Vector instance is used to synchronize the JavaDoc does not give any guarantee about that and - at least theoretically - Sun/Oracle could change that and synchronize on another instance. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/