<?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: Threads and Swing</title>
	<atom:link href="http://netzwerg.ch/?feed=rss2&#038;p=137" rel="self" type="application/rss+xml" />
	<link>http://netzwerg.ch/?p=137</link>
	<description>by Rahel Lüthy</description>
	<lastBuildDate>Tue, 20 Mar 2012 12:40:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: nj</title>
		<link>http://netzwerg.ch/?p=137#comment-151</link>
		<dc:creator>nj</dc:creator>
		<pubDate>Thu, 21 Jun 2007 13:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://heiterebeck.wordpress.com/2007/06/20/threads-and-swing#comment-151</guid>
		<description>Sorry, I was having a brain freeze.  No you don&#039;t, but unless the result of your UI action is to launch a new Window, you will always need to use the EDT and therefore the boiler plate will already exists.  Given my intense dislike of popup windows and dialogs in applications I almost always try to &quot;change&quot; the existing ui to accommodate the modified ui rather than to display a new window.  Because of this, the boiler plate already exists in the vast majority of my swing code already.  An example of this is painting a busy overlay on a component rather than popping up a busy dialog.</description>
		<content:encoded><![CDATA[<p>Sorry, I was having a brain freeze.  No you don&#8217;t, but unless the result of your UI action is to launch a new Window, you will always need to use the EDT and therefore the boiler plate will already exists.  Given my intense dislike of popup windows and dialogs in applications I almost always try to &#8220;change&#8221; the existing ui to accommodate the modified ui rather than to display a new window.  Because of this, the boiler plate already exists in the vast majority of my swing code already.  An example of this is painting a busy overlay on a component rather than popping up a busy dialog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rahel luethy</title>
		<link>http://netzwerg.ch/?p=137#comment-150</link>
		<dc:creator>rahel luethy</dc:creator>
		<pubDate>Thu, 21 Jun 2007 07:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://heiterebeck.wordpress.com/2007/06/20/threads-and-swing#comment-150</guid>
		<description>nj — thanks for sharing your thoughts!what i don&#039;t quite understand is (4):&quot;if you&#039;re outside [the EDT] you would have to use the EDT to realise the component anyway&quot;.i had the impression that the original &quot;single thread rule&quot; didn&#039;t require the realization to happen in the EDT, it only said that all code that altered or accessed component state after the realization, was required to run in the EDT.in other words, calling setVisible(true) in the main thread used to be totally acceptable.</description>
		<content:encoded><![CDATA[<p>nj — thanks for sharing your thoughts!what i don&#8217;t quite understand is (4):&#8221;if you&#8217;re outside [the EDT] you would have to use the EDT to realise the component anyway&#8221;.i had the impression that the original &#8220;single thread rule&#8221; didn&#8217;t require the realization to happen in the EDT, it only said that all code that altered or accessed component state after the realization, was required to run in the EDT.in other words, calling setVisible(true) in the main thread used to be totally acceptable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nj</title>
		<link>http://netzwerg.ch/?p=137#comment-149</link>
		<dc:creator>nj</dc:creator>
		<pubDate>Thu, 21 Jun 2007 07:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://heiterebeck.wordpress.com/2007/06/20/threads-and-swing#comment-149</guid>
		<description>I was aware that we are told to do everything in the EDT, including component construction, but I still don&#039;t do it out of habit.I also do recall the text components being blamed for the potential deadlocks, but I have never seen any error myself.It feels like the haze surrounding the topic is because potential bugs have been discovered and a couple of deadlocks have been produced without anyone getting any hard answers.The truth of the matter is that if sun say we should construct components in the EDT then we probably should.  That&#039;s ok because:1) Constructing a component having already constructed its model takes no time at all and you have up to 200ms (which is my baseline) of complete freeze before a user thinks the application is frozen (although it will feel slow to them)1a) Realising and painting a component for the first time was probably the expensive thing anyway and the previous rule said that already had to be in the EDT, so construction time is negligible.2) A common pattern that I use it to assert(SwingUtilities.isEventDispatchThread()) in every single public methods of my component&#039;s API.  That is a nice way to spot misuse of your swing components (especially in your libs), but when components are constructed outside the EDT these asserts will fail and as a result you will probably remove them.  If the construct in EDT rule is forced you will keep them.3) From what people are saying, you&#039;re not going to find the problem anyway - it&#039;ll be your customer.4) Peoples&#039; arguments that it causes additional boiler plate is complete rubbish.  Even at app construction time you needed to use the EDT to make the thing visible, so the boiler plate already existed.  From that point on you are either inside the EDT or outside.  If you&#039;re inside then no boiler plate, if you&#039;re outside you would have to use the EDT to realise the component anyway so that boiler plate already existed in your swing code that wasn&#039;t constructing components inside the EDT.My answer as a swing expert is that I don&#039;t know, but all arguments that I can think of point to following their advise and constructing in the EDT.</description>
		<content:encoded><![CDATA[<p>I was aware that we are told to do everything in the EDT, including component construction, but I still don&#8217;t do it out of habit.I also do recall the text components being blamed for the potential deadlocks, but I have never seen any error myself.It feels like the haze surrounding the topic is because potential bugs have been discovered and a couple of deadlocks have been produced without anyone getting any hard answers.The truth of the matter is that if sun say we should construct components in the EDT then we probably should.  That&#8217;s ok because:1) Constructing a component having already constructed its model takes no time at all and you have up to 200ms (which is my baseline) of complete freeze before a user thinks the application is frozen (although it will feel slow to them)1a) Realising and painting a component for the first time was probably the expensive thing anyway and the previous rule said that already had to be in the EDT, so construction time is negligible.2) A common pattern that I use it to assert(SwingUtilities.isEventDispatchThread()) in every single public methods of my component&#8217;s API.  That is a nice way to spot misuse of your swing components (especially in your libs), but when components are constructed outside the EDT these asserts will fail and as a result you will probably remove them.  If the construct in EDT rule is forced you will keep them.3) From what people are saying, you&#8217;re not going to find the problem anyway &#8211; it&#8217;ll be your customer.4) Peoples&#8217; arguments that it causes additional boiler plate is complete rubbish.  Even at app construction time you needed to use the EDT to make the thing visible, so the boiler plate already existed.  From that point on you are either inside the EDT or outside.  If you&#8217;re inside then no boiler plate, if you&#8217;re outside you would have to use the EDT to realise the component anyway so that boiler plate already existed in your swing code that wasn&#8217;t constructing components inside the EDT.My answer as a swing expert is that I don&#8217;t know, but all arguments that I can think of point to following their advise and constructing in the EDT.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

