<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Concurrency and list.getLast()</title>
	<atom:link href="http://almaer.com/blog/concurrency-and-listgetlast/feed" rel="self" type="application/rss+xml" />
	<link>http://almaer.com/blog/concurrency-and-listgetlast</link>
	<description>blogging about life, the universe, and everything tech</description>
	<lastBuildDate>Sat, 08 Sep 2012 07:06:53 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: David Roussel</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32137</link>
		<dc:creator>David Roussel</dc:creator>
		<pubDate>Mon, 15 May 2006 12:41:53 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32137</guid>
		<description>Yim:  It&#039;s on LinkedList.

But, yes, why&#039;s it not on List, as I tend to use the interface rather than the implementation for my references.

Also, why does LinkedHashSet not implement List too?
</description>
		<content:encoded><![CDATA[<p>Yim:  It&#8217;s on LinkedList.</p>
<p>But, yes, why&#8217;s it not on List, as I tend to use the interface rather than the implementation for my references.</p>
<p>Also, why does LinkedHashSet not implement List too?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carfield Yim</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32136</link>
		<dc:creator>Carfield Yim</dc:creator>
		<pubDate>Wed, 26 Apr 2006 09:19:10 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32136</guid>
		<description>Do I miss anything? I cannot find list.getLast() at java.util.List interface
</description>
		<content:encoded><![CDATA[<p>Do I miss anything? I cannot find list.getLast() at java.util.List interface</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Emmanuel Pirsch</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32135</link>
		<dc:creator>Emmanuel Pirsch</dc:creator>
		<pubDate>Thu, 20 Apr 2006 15:46:37 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32135</guid>
		<description>Most List implementation are not synchronized by default. So list.getLast() would be just as bad as list.get(list.size()-1).

Dealing with concurrency issues is more complicated than just adding a synchronized modifier to a method or using a synchronized block. Only a good design and well defined concurrency path will make an multithreading application well behaved.

</description>
		<content:encoded><![CDATA[<p>Most List implementation are not synchronized by default. So list.getLast() would be just as bad as list.get(list.size()-1).</p>
<p>Dealing with concurrency issues is more complicated than just adding a synchronized modifier to a method or using a synchronized block. Only a good design and well defined concurrency path will make an multithreading application well behaved.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jed Wesley-Smith</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32134</link>
		<dc:creator>Jed Wesley-Smith</dc:creator>
		<pubDate>Thu, 20 Apr 2006 10:19:42 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32134</guid>
		<description>Oops, I obviously meant extends List...
</description>
		<content:encoded><![CDATA[<p>Oops, I obviously meant extends List&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jed Wesley-Smith</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32133</link>
		<dc:creator>Jed Wesley-Smith</dc:creator>
		<pubDate>Thu, 20 Apr 2006 09:54:44 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32133</guid>
		<description>But any unguarded operations on a Collection has potentially the same problem:

if (!list.isEmpty()) object = list.get(0);

So you need to guard any set multiple accesses to make them atomic. It is fairly trivial to create a ReadWriteList implementation that transparently handles a ReadWriteLock for you, then you can guard your writes transparently:

interface ReadWriteList extends ArrayList, ReadWriteLock {}

ReadWriteList list = new ReadWriteListWrapper(new ArrayList());

list.readLock().lock();
if (!list.isEmpty()) object = list.get(0);
list.readLock().unlock();

You need to maintain your own lock/unlock blocks though, and you can&#039;t transparently lock down your iterators unfortunately.
</description>
		<content:encoded><![CDATA[<p>But any unguarded operations on a Collection has potentially the same problem:</p>
<p>if (!list.isEmpty()) object = list.get(0);</p>
<p>So you need to guard any set multiple accesses to make them atomic. It is fairly trivial to create a ReadWriteList implementation that transparently handles a ReadWriteLock for you, then you can guard your writes transparently:</p>
<p>interface ReadWriteList extends ArrayList, ReadWriteLock {}</p>
<p>ReadWriteList list = new ReadWriteListWrapper(new ArrayList());</p>
<p>list.readLock().lock();<br />
if (!list.isEmpty()) object = list.get(0);<br />
list.readLock().unlock();</p>
<p>You need to maintain your own lock/unlock blocks though, and you can&#8217;t transparently lock down your iterators unfortunately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Carreira</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32132</link>
		<dc:creator>Jason Carreira</dc:creator>
		<pubDate>Thu, 20 Apr 2006 04:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32132</guid>
		<description>Yep, it&#039;s been on order for a while now... hope it ships soon...
</description>
		<content:encoded><![CDATA[<p>Yep, it&#8217;s been on order for a while now&#8230; hope it ships soon&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Carreira</title>
		<link>http://almaer.com/blog/concurrency-and-listgetlast/comment-page-1#comment-32131</link>
		<dc:creator>Jason Carreira</dc:creator>
		<pubDate>Thu, 20 Apr 2006 04:07:42 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog2/concurrency-and-listgetlast#comment-32131</guid>
		<description>Yep, it&#039;s been on order for a while now... hope it ships soon...
</description>
		<content:encoded><![CDATA[<p>Yep, it&#8217;s been on order for a while now&#8230; hope it ships soon&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
