<?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: What do we really know about non-blocking concurrency in Java?</title>
	<atom:link href="http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/</link>
	<description>no buzzwords allowed</description>
	<lastBuildDate>Wed, 01 Feb 2012 18:42:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BlogCop</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-34420</link>
		<dc:creator>BlogCop</dc:creator>
		<pubDate>Sat, 05 Jun 2010 15:34:59 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-34420</guid>
		<description>We now have your blog post available on Blogcop.com  &lt;a href=&quot;http://www.blogcop.com/blog/What-do-we-really-know-about-non-blocking-concurrency-in-Java/MzI4NTY0&quot; rel=&quot;nofollow&quot;&gt;What do we really know about non blocking concurrency in Java&lt;/a&gt;.  To get your other posts on BlogCop and get greater exposure add a link to us on your site.</description>
		<content:encoded><![CDATA[<p>We now have your blog post available on Blogcop.com  <a href="http://www.blogcop.com/blog/What-do-we-really-know-about-non-blocking-concurrency-in-Java/MzI4NTY0" rel="nofollow">What do we really know about non blocking concurrency in Java</a>.  To get your other posts on BlogCop and get greater exposure add a link to us on your site.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-3209</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Thu, 13 Nov 2008 10:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-3209</guid>
		<description>@Pesco

Seriously? ++ is done by one thread *only*. concurrency is not important here. Generally only one thread writes.</description>
		<content:encoded><![CDATA[<p>@Pesco</p>
<p>Seriously? ++ is done by one thread *only*. concurrency is not important here. Generally only one thread writes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris Andreou</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2843</link>
		<dc:creator>Dimitris Andreou</dc:creator>
		<pubDate>Wed, 29 Oct 2008 09:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2843</guid>
		<description>This is not guarranteed to work, since the reader threads do not access the cacheFlush volatile, written by the writer thread. If it works, it is merely an implementation artifact; there is no happens-before between the write and the read, unless there is some other piggybacking going on that makes it correct...

See chapter 16 of Java Concurrency in Practice.

(Why not just use an AtomicInteger#getAndIncrement()?)</description>
		<content:encoded><![CDATA[<p>This is not guarranteed to work, since the reader threads do not access the cacheFlush volatile, written by the writer thread. If it works, it is merely an implementation artifact; there is no happens-before between the write and the read, unless there is some other piggybacking going on that makes it correct&#8230;</p>
<p>See chapter 16 of Java Concurrency in Practice.</p>
<p>(Why not just use an AtomicInteger#getAndIncrement()?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathias Ricken</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2838</link>
		<dc:creator>Mathias Ricken</dc:creator>
		<pubDate>Wed, 29 Oct 2008 02:20:39 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2838</guid>
		<description>@Jevgeni:

What I was trying to say was that writes to non-volatile variables by thread 1 cannot be reordered past a write to a volatile variable by thread 1 and a read by a volatile variable by thread 2, thread 2 will see all the writes by thread 1.

If you have this structure, there is no race condition for the non-volatile data.

thread1:
1a) write to non-volatile variable A
1b) write to non-volatile variable B
1c) write to volatile variable C

thread2:
2a) read from volatile variable C
2b) read from non-volatile variable A
2c) read from non-volatile variable B

1a and 1b can be permuted, and 2b and 2c can be permuted, but 1a and 1b can&#039;t be moved past 1c, and 2b and 2c can&#039;t be moved ahead of 2a.

That means that you can use volatiles to implement locks:

&quot;The third of these rules [Volatile rule. A write to a volatile field happens before every subsequent read of the same volatile.], the one governing volatile fields, is a stronger guarantee than that made by the original memory model. This is useful because now volatile variables can be used as &#039;guard&#039; variables -- you can now use a volatile field to indicate across threads that some set of actions has been performed, and be confident that those actions will be visible to all other threads.&quot;

(Brian Goetz in &quot;JSR 133 in Public Review&quot;, http://today.java.net/lpt/a/84 )

I&#039;m sorry I didn&#039;t make this clear.</description>
		<content:encoded><![CDATA[<p>@Jevgeni:</p>
<p>What I was trying to say was that writes to non-volatile variables by thread 1 cannot be reordered past a write to a volatile variable by thread 1 and a read by a volatile variable by thread 2, thread 2 will see all the writes by thread 1.</p>
<p>If you have this structure, there is no race condition for the non-volatile data.</p>
<p>thread1:<br />
1a) write to non-volatile variable A<br />
1b) write to non-volatile variable B<br />
1c) write to volatile variable C</p>
<p>thread2:<br />
2a) read from volatile variable C<br />
2b) read from non-volatile variable A<br />
2c) read from non-volatile variable B</p>
<p>1a and 1b can be permuted, and 2b and 2c can be permuted, but 1a and 1b can&#8217;t be moved past 1c, and 2b and 2c can&#8217;t be moved ahead of 2a.</p>
<p>That means that you can use volatiles to implement locks:</p>
<p>&#8220;The third of these rules [Volatile rule. A write to a volatile field happens before every subsequent read of the same volatile.], the one governing volatile fields, is a stronger guarantee than that made by the original memory model. This is useful because now volatile variables can be used as &#8216;guard&#8217; variables &#8212; you can now use a volatile field to indicate across threads that some set of actions has been performed, and be confident that those actions will be visible to all other threads.&#8221;</p>
<p>(Brian Goetz in &#8220;JSR 133 in Public Review&#8221;, <a href="http://today.java.net/lpt/a/84" rel="nofollow">http://today.java.net/lpt/a/84</a> )</p>
<p>I&#8217;m sorry I didn&#8217;t make this clear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2834</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Tue, 28 Oct 2008 20:53:31 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2834</guid>
		<description>@Mathias

Sorry, that isn&#039;t right. If you have several operations in two threads, they will still be competing unless there&#039;s a lock.</description>
		<content:encoded><![CDATA[<p>@Mathias</p>
<p>Sorry, that isn&#8217;t right. If you have several operations in two threads, they will still be competing unless there&#8217;s a lock.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathias Ricken</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2833</link>
		<dc:creator>Mathias Ricken</dc:creator>
		<pubDate>Tue, 28 Oct 2008 20:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2833</guid>
		<description>@Reid: In the new memory model, a write to a volatile variable from one thread and a read from another thread serve as barrier in the order of operations. There is no race condition.</description>
		<content:encoded><![CDATA[<p>@Reid: In the new memory model, a write to a volatile variable from one thread and a read from another thread serve as barrier in the order of operations. There is no race condition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2832</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Tue, 28 Oct 2008 20:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2832</guid>
		<description>@Reid

I don&#039;t really see where do I imply that. Race conditions and synchronization just wasn&#039;t relevant to my very specific problem.</description>
		<content:encoded><![CDATA[<p>@Reid</p>
<p>I don&#8217;t really see where do I imply that. Race conditions and synchronization just wasn&#8217;t relevant to my very specific problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reid K</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2831</link>
		<dc:creator>Reid K</dc:creator>
		<pubDate>Tue, 28 Oct 2008 18:58:03 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2831</guid>
		<description>You say that the Java memory model is mostly useful for caches, but it&#039;s also important for concurrent garbage collection.  I read this paper about the Sapphire GC a while ago, and the correctness of their implementation is based on synchronization points and the assumption that threads should not have any race conditions, meaning they can&#039;t grab references to objects in other threads without entering a monitor.

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.16.1701</description>
		<content:encoded><![CDATA[<p>You say that the Java memory model is mostly useful for caches, but it&#8217;s also important for concurrent garbage collection.  I read this paper about the Sapphire GC a while ago, and the correctness of their implementation is based on synchronization points and the assumption that threads should not have any race conditions, meaning they can&#8217;t grab references to objects in other threads without entering a monitor.</p>
<p><a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.16.1701" rel="nofollow">http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.16.1701</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2829</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Tue, 28 Oct 2008 18:23:52 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2829</guid>
		<description>@Mathias

Wow, thanks! That is exactly what I was looking for!</description>
		<content:encoded><![CDATA[<p>@Mathias</p>
<p>Wow, thanks! That is exactly what I was looking for!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathias Ricken</title>
		<link>http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/comment-page-1/#comment-2828</link>
		<dc:creator>Mathias Ricken</dc:creator>
		<pubDate>Tue, 28 Oct 2008 18:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=378#comment-2828</guid>
		<description>If you want another reference for that behavior, check out Bill Pugh&#039;s JSR-133 FAQ:

http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#volatile

&quot;Under the new memory model, it is still true that volatile variables cannot be reordered with each other. The difference is that it is now no longer so easy to reorder normal field accesses around them. Writing to a volatile field has the same memory effect as a monitor release, and reading from a volatile field has the same memory effect as a monitor acquire. In effect, because the new memory model places stricter constraints on reordering of volatile field accesses with other field accesses, volatile or not, anything that was visible to thread A when it writes to volatile field f becomes visible to thread B when it reads f.&quot;

The source code in there is basically the same that you have.</description>
		<content:encoded><![CDATA[<p>If you want another reference for that behavior, check out Bill Pugh&#8217;s JSR-133 FAQ:</p>
<p><a href="http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#volatile" rel="nofollow">http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#volatile</a></p>
<p>&#8220;Under the new memory model, it is still true that volatile variables cannot be reordered with each other. The difference is that it is now no longer so easy to reorder normal field accesses around them. Writing to a volatile field has the same memory effect as a monitor release, and reading from a volatile field has the same memory effect as a monitor acquire. In effect, because the new memory model places stricter constraints on reordering of volatile field accesses with other field accesses, volatile or not, anything that was visible to thread A when it writes to volatile field f becomes visible to thread B when it reads f.&#8221;</p>
<p>The source code in there is basically the same that you have.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

