<?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: Java Concurrency Bugs #4: ConcurrentModificationException</title>
	<atom:link href="http://tech.puredanger.com/index.php/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/</link>
	<description>Alex Miller&#039;s technical blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:39:50 -0800</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
	<item>
		<title>By: Alex</title>
		<link>http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/comment-page-1/#comment-262004</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 12 Nov 2010 19:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/#comment-262004</guid>
		<description>@Karthik: Could you be more specific on what kind of collection or map you&#039;re talking about?</description>
		<content:encoded><![CDATA[<p>@Karthik: Could you be more specific on what kind of collection or map you&#8217;re talking about?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthik</title>
		<link>http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/comment-page-1/#comment-262000</link>
		<dc:creator>Karthik</dc:creator>
		<pubDate>Fri, 12 Nov 2010 19:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/#comment-262000</guid>
		<description>Hi,

What happens to these concurrent lists when we say we are iterating the 3rd item on the list but another thread concurrently modifies to insert an item at index 1 so this is before the current element. How does the list behave now?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>What happens to these concurrent lists when we say we are iterating the 3rd item on the list but another thread concurrently modifies to insert an item at index 1 so this is before the current element. How does the list behave now?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Linden</title>
		<link>http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/comment-page-1/#comment-183866</link>
		<dc:creator>Paul Linden</dc:creator>
		<pubDate>Fri, 01 Jan 2010 20:05:09 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/#comment-183866</guid>
		<description>Ok, I know this is an old post, but even 11 months later, this series is a great resource. Knowing what can go wrong is a great step towards fixing and avoiding these bugs.

Anyway, reading over the comments, I decided to answer Dimitris&#039; comment about this almost never happening in real code.

I recently worked on a web application (an inhouse content management app) that stored some seldom-changing globally accessible data in a static ArrayList, to avoid having to read it from the db for everyone. This data was mutable, and anyone using the app could delete instances from the db ... the delete (or add or modify) operations would also update the ArrayList. 

The number of users was low (maybe 10 at a time, max) and it was &lt;i&gt;unlikely&lt;/i&gt; that two would be working on the same operations at the same time, but we did get the occasional CME (a couple of times a month?), resulting in error pages shown to the user, due to this very problem.

Of course, it was a design problem due to the original developer not thinking about concurrent programming.</description>
		<content:encoded><![CDATA[<p>Ok, I know this is an old post, but even 11 months later, this series is a great resource. Knowing what can go wrong is a great step towards fixing and avoiding these bugs.</p>
<p>Anyway, reading over the comments, I decided to answer Dimitris&#8217; comment about this almost never happening in real code.</p>
<p>I recently worked on a web application (an inhouse content management app) that stored some seldom-changing globally accessible data in a static ArrayList, to avoid having to read it from the db for everyone. This data was mutable, and anyone using the app could delete instances from the db &#8230; the delete (or add or modify) operations would also update the ArrayList. </p>
<p>The number of users was low (maybe 10 at a time, max) and it was <i>unlikely</i> that two would be working on the same operations at the same time, but we did get the occasional CME (a couple of times a month?), resulting in error pages shown to the user, due to this very problem.</p>
<p>Of course, it was a design problem due to the original developer not thinking about concurrent programming.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Srgjan Srepfler</title>
		<link>http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/comment-page-1/#comment-141567</link>
		<dc:creator>Srgjan Srepfler</dc:creator>
		<pubDate>Mon, 09 Feb 2009 12:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/#comment-141567</guid>
		<description>I&#039;ve actually had this problem and I went to modify a collection copy. Had I only known about the iterator.remove() method!
Excellent post!</description>
		<content:encoded><![CDATA[<p>I&#8217;ve actually had this problem and I went to modify a collection copy. Had I only known about the iterator.remove() method!<br />
Excellent post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris Andreou</title>
		<link>http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/comment-page-1/#comment-140265</link>
		<dc:creator>Dimitris Andreou</dc:creator>
		<pubDate>Wed, 04 Feb 2009 21:21:47 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/#comment-140265</guid>
		<description>Alex, I&#039;m not familiar with Glazed Lists, but I think even Eric&#039;s example is single-threaded (in swing&#039;s thread in particular). To be honest, I&#039;ve never ever encountered this bug in multi-threaded code, although it surely is possible to happen.

I understand that it would be difficult to support meaningfully (single-threaded) modification in an ArrayList or others, but for example LinkedList&#039;s iterator is just a pity that behaves like this (it could cope perfectly well with in-thread modifications).

Arbitrary non-thread-safe classes trying to protect as from unsynchronized access (in &#039;some&#039; cases, if we are lucky) is just absurd. Just imagine this approach being taken in any non-thread-safe class. I think Josh&#039;s call was the wrong one in this case, and the exception should have been more honest: it would be better to have something like &quot;ModificationWhileIteratingNotSupportedException&quot; instead of &quot;ConcurrentModificationException&quot;, and just in those collections that indeed couldn&#039;t support this.</description>
		<content:encoded><![CDATA[<p>Alex, I&#8217;m not familiar with Glazed Lists, but I think even Eric&#8217;s example is single-threaded (in swing&#8217;s thread in particular). To be honest, I&#8217;ve never ever encountered this bug in multi-threaded code, although it surely is possible to happen.</p>
<p>I understand that it would be difficult to support meaningfully (single-threaded) modification in an ArrayList or others, but for example LinkedList&#8217;s iterator is just a pity that behaves like this (it could cope perfectly well with in-thread modifications).</p>
<p>Arbitrary non-thread-safe classes trying to protect as from unsynchronized access (in &#8216;some&#8217; cases, if we are lucky) is just absurd. Just imagine this approach being taken in any non-thread-safe class. I think Josh&#8217;s call was the wrong one in this case, and the exception should have been more honest: it would be better to have something like &#8220;ModificationWhileIteratingNotSupportedException&#8221; instead of &#8220;ConcurrentModificationException&#8221;, and just in those collections that indeed couldn&#8217;t support this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

