Re: JavaMemoryModel: Bugs in Tiger beta 1

From: Thomas Hawtin (
Date: Thu Mar 11 2004 - 16:36:29 EST

Joseph Bowbeer wrote:
> Tom Hawtin writes:
>>Only this afternoon I spotted crimes committed on
>>javax.swing.text.html.HTMLEditorKit.defaultStyles and defaultParser.
> Swing is a single-threaded subsystem and therefore should be mostly immune -
> except at the boundaries, where it interacts with the multi-threaded world,
> and in javax.swing.text.AbstractDocument, where it explicitly admits
> asynchronous changes. [Aside: I'd give worlds to know just how the
> notifications from these changes are communicated to the rest of the
> single-threaded subsystem in a thread-safe way -- without first relaying
> these notifications to Swing's input-event thread.]
> When you say that accesses to the static, non-volatile defaultStyles and
> defaultParser are not correctly synchronized, I assume you've concluded that
> these accesses can result from asynchronous changes to the underlying
> AbstractDocument. (right?)

Components (and friends) that have been shown should only be accessed
from the AWT Event Dispatch Thread (including the initial show, which
most programs and examples get wrong (and 1.5 seems to tickle these bugs
more easily)). However, it is common practice to prebuild the GUI
outside of the AWT thread to help make the application more responsive.
In particular if you are using HTMLEditorKey you are probably at least
loading from a file if not downloading across the internet. So, unless
you want your application to be as responsive as Mozilla/Netscape at
least some of the work should be done in a different thread.

But then the whole text.html handling of downloading referenced image
and stylesheets and submitting forms is less than pleasant.

Tom Hawtin

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:59 EDT