From: markspace on
Christian Kaufhold wrote:

> Lew <lew(a)lewscanon.com> wrote:
>> I worried about the 'view.append()' actions seeming not to be on the
>> EDT until I looked at the Javadocs for 'JTextArea#append()':
>> "This method is thread safe, although most Swing methods are not.
>> Please see _Threads and Swing_ for more information."

> The documentation is wrong, as has been discussed already years ago, mostly
> in comp.lang.java.gui


You appear to be correct. How odd.

Even ignoring problems with mutual exclusion and stuff happening "at the
same time", the calls append() and setText() make no attempt at
synchronization or any sort of happens-before relationship. The
underling call to Document.insert isn't noted to be thread safe either,
so I don't know what prompted the Swing team to mark this method as
thread safe.

(OTOH, the underlying Document doesn't have the usual Swing note about
not being thread safe, so perhaps the entire class is thread safe. Not
sure. There's nothing on thread safety documented at all for Document,
either way.)