[concurrency-interest] Swing translates InterruptedException to Error

Gregg Wonderly gregg at cytetech.com
Tue Dec 18 16:03:34 EST 2007

Thomas Hawtin wrote:
> Gregg Wonderly wrote:
>> Darius Polonis wrote:
>>> Allright, in that case I'll just wrap my code and use  
>>> SwingUtilities.invokeLater(). But I am not sure the Swing folks have  
>>> to come to your conclusion, too, as the javadoc still states  
>>> AbstractDocument.insertString() would be thread safe...
>> They used to say that an unrealized component could be manipulated outside of 
>> the event thread.  This is now, no longer possible.  It is important to write 
>> any code that touches a swing component to use the event dispatch thread.
> A number of methods explicitly state that they are thread-safe. For 
> instance, JTextArea.append. But given the interface of Document or even 
> AbstractDocument, how would you write such a thing correctly?

My experience is that for any text component, JLabel included, append() or 
setText() et.al, will cause resize() to be called which will assert the 
lock-of-doom...  I really think that it is no longer safe to manipulate anything 
outside of the event thread based on what I've experienced in a multi threaded 
desktop UI which I wrote.  This UI gets new components from dynamic network 
discovery (using Jini) which is a good demonstration of random thread behavior.

Gregg Wonderly

More information about the Concurrency-interest mailing list