<?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: Why ConcurrentHashMap is better than Hashtable and just as good as a HashMap</title>
	<atom:link href="http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html</link>
	<description>Everything java</description>
	<lastBuildDate>Wed, 01 Feb 2012 06:25:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Rags</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-830</link>
		<dc:creator>Rags</dc:creator>
		<pubDate>Fri, 25 Nov 2011 11:29:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-830</guid>
		<description>Better explanation is here: http://stackoverflow.com/questions/2836267/concurrenthashmap-in-java specifically &quot;All operations are threadsafe, but there is no happens before promise like there would be with a synchronized map. What you see when you look in a ConcurrentHashMap is the results of the most recently completed operations. Some of which may have begun significantly later in time than when you started trying to look. It works rather like a read-committed database isolation, whereas a synchronized map works more like a serializable database isolation. – Affe May 14 &#039;10 at 17:46&quot;</description>
		<content:encoded><![CDATA[<p>Better explanation is here: <a href="http://stackoverflow.com/questions/2836267/concurrenthashmap-in-java" rel="nofollow">http://stackoverflow.com/questions/2836267/concurrenthashmap-in-java</a> specifically &#8220;All operations are threadsafe, but there is no happens before promise like there would be with a synchronized map. What you see when you look in a ConcurrentHashMap is the results of the most recently completed operations. Some of which may have begun significantly later in time than when you started trying to look. It works rather like a read-committed database isolation, whereas a synchronized map works more like a serializable database isolation. – Affe May 14 &#8217;10 at 17:46&#8243;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Li</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-798</link>
		<dc:creator>Aaron Li</dc:creator>
		<pubDate>Sat, 17 Sep 2011 03:13:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-798</guid>
		<description>If I am not wrong the maximum number of lock is 2 power 16, not 16 only</description>
		<content:encoded><![CDATA[<p>If I am not wrong the maximum number of lock is 2 power 16, not 16 only</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vivek</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-714</link>
		<dc:creator>Vivek</dc:creator>
		<pubDate>Mon, 07 Feb 2011 16:51:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-714</guid>
		<description>Well,
Your code snippet is not thread-safe if seen from the actual implementation point of view. Bcoz the entire operation of search &amp; insertion of Key should have been an atomic operation but is not.

But however, you still are safe from any threading issues with regard to the above implementation bcoz, the threadId in your case is specific to the calling Thread. So, at any given point in time the Thread will check its own identity in the map and hence you are left safe.</description>
		<content:encoded><![CDATA[<p>Well,<br />
Your code snippet is not thread-safe if seen from the actual implementation point of view. Bcoz the entire operation of search &amp; insertion of Key should have been an atomic operation but is not.</p>
<p>But however, you still are safe from any threading issues with regard to the above implementation bcoz, the threadId in your case is specific to the calling Thread. So, at any given point in time the Thread will check its own identity in the map and hence you are left safe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javin Paul</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-705</link>
		<dc:creator>Javin Paul</dc:creator>
		<pubDate>Sat, 08 Jan 2011 07:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-705</guid>
		<description>ConcurrentHashMap is indeed best choice in case of multithreaded environment if numbers of reader is much greater than number of writer to avoid contention and to increase throughput and performance but deciding between &lt;a href=&quot;http://javarevisited.blogspot.com/2010/10/what-is-difference-between-synchronized.html&quot; rel=&quot;nofollow&quot;&gt; SynchrnozedHashMap and ConcurrentHashMap &lt;/a&gt; is still requires understanding of usecases and actual environment.

Thanks
Javin
&lt;a href=&quot;http://javarevisited.blogspot.com/2010/12/fix-protocol-interview-questions.html&quot; rel=&quot;nofollow&quot;&gt;FIX Protocol tutorial&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>ConcurrentHashMap is indeed best choice in case of multithreaded environment if numbers of reader is much greater than number of writer to avoid contention and to increase throughput and performance but deciding between <a href="http://javarevisited.blogspot.com/2010/10/what-is-difference-between-synchronized.html" rel="nofollow"> SynchrnozedHashMap and ConcurrentHashMap </a> is still requires understanding of usecases and actual environment.</p>
<p>Thanks<br />
Javin<br />
<a href="http://javarevisited.blogspot.com/2010/12/fix-protocol-interview-questions.html" rel="nofollow">FIX Protocol tutorial</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anshuiitk</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-692</link>
		<dc:creator>anshuiitk</dc:creator>
		<pubDate>Sun, 12 Dec 2010 19:27:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-692</guid>
		<description>In the 5th para you do explain about how CHMs could have null. I wrote an article about why CHMs dont offer null values (http://anshuiitk.blogspot.com/2010/12/why-concurrenthashmap-does-not-support.html). However the best tradeof is to use putIfAbsent in case of CHMs. Its very important. Nice and informative article.</description>
		<content:encoded><![CDATA[<p>In the 5th para you do explain about how CHMs could have null. I wrote an article about why CHMs dont offer null values (<a href="http://anshuiitk.blogspot.com/2010/12/why-concurrenthashmap-does-not-support.html" rel="nofollow">http://anshuiitk.blogspot.com/2010/12/why-concurrenthashmap-does-not-support.html</a>). However the best tradeof is to use putIfAbsent in case of CHMs. Its very important. Nice and informative article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shrini</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-611</link>
		<dc:creator>Shrini</dc:creator>
		<pubDate>Thu, 04 Mar 2010 05:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-611</guid>
		<description>@rajeshksv

How about storing context in thread local ? But this does not answer your question though ;)</description>
		<content:encoded><![CDATA[<p>@rajeshksv</p>
<p>How about storing context in thread local ? But this does not answer your question though <img src='http://www.codercorp.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WasserbettenGuerilla</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-597</link>
		<dc:creator>WasserbettenGuerilla</dc:creator>
		<pubDate>Thu, 28 Jan 2010 17:58:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-597</guid>
		<description>Im wondering if the ConcurrentHashMap is only fast if it comes to multiple thread operations. I tried it in a single threaded application and i performed worse than a hashtable.. So what if there are only two threads accessing the datastructure, is Hastable or CHM faster?

Regards</description>
		<content:encoded><![CDATA[<p>Im wondering if the ConcurrentHashMap is only fast if it comes to multiple thread operations. I tried it in a single threaded application and i performed worse than a hashtable.. So what if there are only two threads accessing the datastructure, is Hastable or CHM faster?</p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rajeshksv</title>
		<link>http://www.codercorp.com/blog/java/why-concurrenthashmap-is-better-than-hashtable-and-just-as-good-hashmap.html/comment-page-1#comment-511</link>
		<dc:creator>rajeshksv</dc:creator>
		<pubDate>Mon, 14 Sep 2009 06:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.codercorp.com/blog/?p=53#comment-511</guid>
		<description>Nice tutorial.It clearly explains why Concurrent hashmap is to be used
 I am using Concurrent Hashmap for this code--- Is this threadsafe??
Why cant I use hashmap atleast in this case where no two threads access the same key(since I am using threadId itself as hashmap key) and no thread iterates over the map and all the threads will only put/get values


private static Map&lt;String,Context&gt; threadData = new ConcurrentHashMap&lt;String,Context&gt;();
public static Context getContext() {
		String threadId = String.valueOf(Thread.currentThread().getId());
		if (threadData.get(threadId) == null) {
			Context context = new Context();
			threadData.put(threadId, context);
		}
		return (threadData.get(threadId));
	}

Thanks in Advance</description>
		<content:encoded><![CDATA[<p>Nice tutorial.It clearly explains why Concurrent hashmap is to be used<br />
 I am using Concurrent Hashmap for this code&#8212; Is this threadsafe??<br />
Why cant I use hashmap atleast in this case where no two threads access the same key(since I am using threadId itself as hashmap key) and no thread iterates over the map and all the threads will only put/get values</p>
<p>private static Map&lt;String,Context&gt; threadData = new ConcurrentHashMap&lt;String,Context&gt;();<br />
public static Context getContext() {<br />
		String threadId = String.valueOf(Thread.currentThread().getId());<br />
		if (threadData.get(threadId) == null) {<br />
			Context context = new Context();<br />
			threadData.put(threadId, context);<br />
		}<br />
		return (threadData.get(threadId));<br />
	}</p>
<p>Thanks in Advance</p>
]]></content:encoded>
	</item>
</channel>
</rss>

