<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Concurrency and HashMap</title>
	<atom:link href="http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/feed/" rel="self" type="application/rss+xml" />
	<link>http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/</link>
	<description></description>
	<lastBuildDate>Tue, 11 Aug 2009 16:12:23 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Laurence Vanhelsuwe</title>
		<link>http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/#comment-155</link>
		<dc:creator>Laurence Vanhelsuwe</dc:creator>
		<pubDate>Mon, 13 Jul 2009 08:58:33 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=25#comment-155</guid>
		<description>Flagging down mutlithreaded accesses of NON threadsafe containers was one of the original features of our &lt;a href=&quot;http://www.collectionspy.com&quot; rel=&quot;nofollow&quot;&gt; profiler&lt;/a&gt;. And, sure enough, most programs we&#039;ve profiled seem to play Russian roulette with multithreaded accesses to HashMaps.</description>
		<content:encoded><![CDATA[<p>Flagging down mutlithreaded accesses of NON threadsafe containers was one of the original features of our <a href="http://www.collectionspy.com" rel="nofollow"> profiler</a>. And, sure enough, most programs we&#8217;ve profiled seem to play Russian roulette with multithreaded accesses to HashMaps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul</title>
		<link>http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/#comment-152</link>
		<dc:creator>Rahul</dc:creator>
		<pubDate>Tue, 07 Apr 2009 08:37:35 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=25#comment-152</guid>
		<description>I dont think the rule of thumb “use Thread safe collections
wherever concurrency is involved” is much of a use.
Consider you want to use HashTable instead of HashMap, when concurrency is required. As far as i know, only the individual methods in HashTable are synchronized, there is nothing that prevents Thread T2 from changing that HashTable, when thread T1 has come out of one method, say put() and is still to enter into get().
So, where concurrency is important, it is important to write code that takes care of it, instead of using Thread safe collections(which are obviously better than non thread safe collections, like HashMap in this case)</description>
		<content:encoded><![CDATA[<p>I dont think the rule of thumb “use Thread safe collections<br />
wherever concurrency is involved” is much of a use.<br />
Consider you want to use HashTable instead of HashMap, when concurrency is required. As far as i know, only the individual methods in HashTable are synchronized, there is nothing that prevents Thread T2 from changing that HashTable, when thread T1 has come out of one method, say put() and is still to enter into get().<br />
So, where concurrency is important, it is important to write code that takes care of it, instead of using Thread safe collections(which are obviously better than non thread safe collections, like HashMap in this case)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael B</title>
		<link>http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/#comment-81</link>
		<dc:creator>Michael B</dc:creator>
		<pubDate>Tue, 01 Jul 2008 21:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=25#comment-81</guid>
		<description>&quot;Finally i will leave you with this interesting bug in Java which says HashMap can...&quot;
Wrong choice of words as it&#039;s not a bug. A pitfall for the uninitiated? sure.

not thread-safe means not thread-safe. It&#039;s a visibility issue that is goign to stay in there as it&#039;s outside the scope of what a hashmap is suppose to do, use a ConcurrentMap implementation.

For an other perfect example where ppl also used there &#039;smart creativity&#039; check out:
http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

dj wrote:
&quot;Nicely written. But I was not able to reproduce it. any clues ?&quot;
Try reading this blog: http://java.dzone.com/articles/but-it-works-on-my-machine
In short the jvm you used might provide more visibility that it has too. The bottom line that which isn&#039;t guaranteed to work is going to bit you in the ass -&gt; small adaptation of murphies law.</description>
		<content:encoded><![CDATA[<p>&#8220;Finally i will leave you with this interesting bug in Java which says HashMap can&#8230;&#8221;<br />
Wrong choice of words as it&#8217;s not a bug. A pitfall for the uninitiated? sure.</p>
<p>not thread-safe means not thread-safe. It&#8217;s a visibility issue that is goign to stay in there as it&#8217;s outside the scope of what a hashmap is suppose to do, use a ConcurrentMap implementation.</p>
<p>For an other perfect example where ppl also used there &#8217;smart creativity&#8217; check out:<br />
<a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html" rel="nofollow">http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html</a></p>
<p>dj wrote:<br />
&#8220;Nicely written. But I was not able to reproduce it. any clues ?&#8221;<br />
Try reading this blog: <a href="http://java.dzone.com/articles/but-it-works-on-my-machine" rel="nofollow">http://java.dzone.com/articles/but-it-works-on-my-machine</a><br />
In short the jvm you used might provide more visibility that it has too. The bottom line that which isn&#8217;t guaranteed to work is going to bit you in the ass -&gt; small adaptation of murphies law.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dj</title>
		<link>http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/#comment-80</link>
		<dc:creator>dj</dc:creator>
		<pubDate>Tue, 01 Jul 2008 04:34:56 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=25#comment-80</guid>
		<description>Nicely written. But I was not able to reproduce it. any clues ?</description>
		<content:encoded><![CDATA[<p>Nicely written. But I was not able to reproduce it. any clues ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://pitfalls.wordpress.com/2008/06/29/concurrencyandhashmap/#comment-77</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 30 Jun 2008 06:20:22 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=25#comment-77</guid>
		<description>Nice, well explained article. I think this could do really well on JavaLobby. If you&#039;re interested in reposting there, send me a mail and we can organise it

James</description>
		<content:encoded><![CDATA[<p>Nice, well explained article. I think this could do really well on JavaLobby. If you&#8217;re interested in reposting there, send me a mail and we can organise it</p>
<p>James</p>
]]></content:encoded>
	</item>
</channel>
</rss>
