[concurrency-interest] Confused about Component.getTreeLock()

Thomas Hawtin tackline at tackline.plus.com
Tue Mar 6 12:20:26 EST 2007


Gregg Wonderly wrote:
> 
> The standing statement from the swing development team WAS that you should never 
> touch a "realized" component without using the event dispatch thread.  As of 
> JDK1.5, they've ammended this statement to demand that anything which can cause 
> a component to be realized must be in the event dispatch thread.  This includes 
> things like Window.pack() and Window.setVisible(true).

For Swing components. In fact other stuff, like JTextField via 
documents, can use invokeLater internally and therefore screw up. So now 
it's do everything on the EDT (with a few exceptions). It turns out that 
the explicit multithreading capabilities of the Swing text doesn't 
actually work or indeed make any sense.

I think there's probably a more general lesson in there.

Tom Hawtin


More information about the Concurrency-interest mailing list