Issue
According to Swing tutorial:
Some Swing component methods are labelled "thread safe" in the API specification; these can be safely invoked from any thread. All other Swing component methods must be invoked from the event dispatch thread. Programs that ignore this rule may function correctly most of the time, but are subject to unpredictable errors that are difficult to reproduce.
But what are these Swing component methods that are labelled "thread safe"? Are there actually any?
Update / bounty:
Is there a complete list of thread-safe swing methods? (The thread-safe Swing methods seems to be quite rare, so such list can't be too long...)
Solution
Google taught me that at least those are threadsafe. Here's an overview for the case that the link get broken again:
JTextPane
replaceSelection()
insertComponent()
insertIcon()
setLogicalStyle()
setCharacterAttributes()
setParagraphAttributes()
JTextArea
insert()
append()
replaceRange()
JTextComponent
replaceSelection()
setText()
print()
getPrintable()
UndoManager
- All methods.
DefaultStyledDocument
insert()
setLogicalStyle()
setCharacterAttributes()
setParagraphAttributes()
StyleContext
addAttribute()
addAttributes()
removeAttribute()
removeAttributes()
reclaim()
AbstractDocument
render()
remove()
insertString()
createPosition()
PlainDocument
insertString()
HTMLDocument
setParagraphAttributes()
Answered By - BalusC
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.