根据摇摆教程:
一些 Swing 组件方法在 API 规范中被标记为“线程安全”;这些可以从任何线程安全地调用。所有其他 Swing 组件方法都必须从事件分派线程调用。忽略此规则的程序可能在大多数情况下都能正常运行,但会出现难以重现的不可预测的错误。
但是这些被标记为“线程安全”的 Swing 组件方法是什么呢?真的有吗?
更新/赏金:
有没有完整列表线程安全的摆动方法? (线程安全的 Swing 方法似乎很少见,所以这样的列表不能太长......)
谷歌至少告诉我those是线程安全的。以下是链接再次损坏的情况的概述:
-
JTextPane
replaceSelection()
insertComponent()
insertIcon()
setLogicalStyle()
setCharacterAttributes()
setParagraphAttributes()
-
JTextArea
insert()
append()
replaceRange()
-
JTextComponent
replaceSelection()
setText()
print()
getPrintable()
-
DefaultStyledDocument
insert()
setLogicalStyle()
setCharacterAttributes()
setParagraphAttributes()
-
StyleContext
addAttribute()
addAttributes()
removeAttribute()
removeAttributes()
reclaim()
-
AbstractDocument
render()
remove()
insertString()
createPosition()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)