<?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 #5: inconsistent synchronization</title>
	<atom:link href="http://tech.puredanger.com/index.php/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/</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/05/13/java-concurrency-bugs-5-inconsistent-synchronization/comment-page-1/#comment-189209</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 25 Mar 2010 16:39:09 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/#comment-189209</guid>
		<description>@Matias: I think I understand what you&#039;re describing.  As to whether it is the equals() method or the other methods that are correct, that&#039;s really hard for me to say without a lot more context about usage of these objects.  If the other generated methods can be accessed from multiple threads, then I would say they are broken without synchronization and FindBugs is correctly detecting a bug.  Sounds like the fix in this case might be in AndroMDA.

Alternately, it could be that AndroMDA is proactively (and incorrectly) generating equals() methods as synchronized.  If these objects are used purely in a thread-confined way, then that synchronization seems unnecessary and again the fix seems like it should be in AndroMDA to not generate the synchronized on equals().</description>
		<content:encoded><![CDATA[<p>@Matias: I think I understand what you&#8217;re describing.  As to whether it is the equals() method or the other methods that are correct, that&#8217;s really hard for me to say without a lot more context about usage of these objects.  If the other generated methods can be accessed from multiple threads, then I would say they are broken without synchronization and FindBugs is correctly detecting a bug.  Sounds like the fix in this case might be in AndroMDA.</p>
<p>Alternately, it could be that AndroMDA is proactively (and incorrectly) generating equals() methods as synchronized.  If these objects are used purely in a thread-confined way, then that synchronization seems unnecessary and again the fix seems like it should be in AndroMDA to not generate the synchronized on equals().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matias</title>
		<link>http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/comment-page-1/#comment-189206</link>
		<dc:creator>Matias</dc:creator>
		<pubDate>Thu, 25 Mar 2010 16:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/#comment-189206</guid>
		<description>Hi Alex,

I have read your article on Inconsistent synchronization. Using the FindBugs tool version 1.39, published 5000 cases under this heading. The majority of them located within the implementation of the VO&#039;s. Analyzing the code generated in these implementations is noted that like implements the methods of the class also implements the equals method. The strange thing is that the class definition and the method in question is generated by AndroMDA, that is self-generating the code under discussion. The peculiarity here is that the equals method is synchronized. Therefore FindBugs detected in the methods of the class itself is not synchronized reading while the equals method if that synchronizes access to them.

Two questions:

Any idea because the equals method is synchronized?
Under your view that there is such a problem is detected FindBugs?

Excuse my poor English and thank you.</description>
		<content:encoded><![CDATA[<p>Hi Alex,</p>
<p>I have read your article on Inconsistent synchronization. Using the FindBugs tool version 1.39, published 5000 cases under this heading. The majority of them located within the implementation of the VO&#8217;s. Analyzing the code generated in these implementations is noted that like implements the methods of the class also implements the equals method. The strange thing is that the class definition and the method in question is generated by AndroMDA, that is self-generating the code under discussion. The peculiarity here is that the equals method is synchronized. Therefore FindBugs detected in the methods of the class itself is not synchronized reading while the equals method if that synchronizes access to them.</p>
<p>Two questions:</p>
<p>Any idea because the equals method is synchronized?<br />
Under your view that there is such a problem is detected FindBugs?</p>
<p>Excuse my poor English and thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/comment-page-1/#comment-164655</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sat, 16 May 2009 23:14:30 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/#comment-164655</guid>
		<description>@Michael B: Yes, this series is about programmer errors ie bugs. I’m not trying to suggest anything is wrong with Java. Not sure how you got that idea?

Sorry spend too much time with ppl who think they found bugs while it&#039;s just there lack of understanding, guess it made me &#039;twitchy&#039;.</description>
		<content:encoded><![CDATA[<p>@Michael B: Yes, this series is about programmer errors ie bugs. I’m not trying to suggest anything is wrong with Java. Not sure how you got that idea?</p>
<p>Sorry spend too much time with ppl who think they found bugs while it&#8217;s just there lack of understanding, guess it made me &#8216;twitchy&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/comment-page-1/#comment-164246</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 14 May 2009 18:39:29 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/#comment-164246</guid>
		<description>@Anton: The last example is thread-safe.  No other thread can see the map until construction completes and at the end of construction final field freeze occurs such that other threads that get this instance of Stooges are guaranteed to see all objects reachable from stooges at the time of freeze, even without synchronization.  

You don&#039;t need to delay assignment because no one else can see the field.  You should consider subclasses though which will have access to the field during their own construction and they could unsafely publish the map or &quot;this&quot;, ruining the semantics we&#039;re trying to achieve.  You could address that by moving the field initialization into the constructor or making the class final.</description>
		<content:encoded><![CDATA[<p>@Anton: The last example is thread-safe.  No other thread can see the map until construction completes and at the end of construction final field freeze occurs such that other threads that get this instance of Stooges are guaranteed to see all objects reachable from stooges at the time of freeze, even without synchronization.  </p>
<p>You don&#8217;t need to delay assignment because no one else can see the field.  You should consider subclasses though which will have access to the field during their own construction and they could unsafely publish the map or &#8220;this&#8221;, ruining the semantics we&#8217;re trying to achieve.  You could address that by moving the field initialization into the constructor or making the class final.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton</title>
		<link>http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/comment-page-1/#comment-164234</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Thu, 14 May 2009 17:02:28 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2009/05/13/java-concurrency-bugs-5-inconsistent-synchronization/#comment-164234</guid>
		<description>Is it guaranteed that the code in the last example is thread-safe? Should not we first populate the map and only then assign it to the field?

Sorry, didn&#039;t sign the first one</description>
		<content:encoded><![CDATA[<p>Is it guaranteed that the code in the last example is thread-safe? Should not we first populate the map and only then assign it to the field?</p>
<p>Sorry, didn&#8217;t sign the first one</p>
]]></content:encoded>
	</item>
</channel>
</rss>

