The java doc says the append method is thread safe. However, I recall that when I tried using the append to the text area from different threads (several months ago), I get jumbled text where thread 1 would append some characters and thread 2 would append some other characters.
So instead of getting STRINGstring in the jtextarea, I get SstTrRINingG.
What differences would there be between:
- synchronizing the append
- bottlenecking appends from different threads through a threadpoolexecutor
- using invokeLater on the EDT
or are they all fine for fixing the issue?
Thanks
While
append()was thread safe with respect to the EDT,append()in Java 7 is not. Appends usinginvokeLater()will be processed in the order in which they are enqueued. A critical examination of the other approaches would require an sscce.