Java: Swing Libraries & Thread Safety

后端 未结 11 2281
后悔当初
后悔当初 2020-11-28 05:27

I\'ve often heard criticism of the lack of thread safety in the Swing libraries. Yet, I am not sure as to what I would be doing in my own code with could cause issues:

11条回答
  •  隐瞒了意图╮
    2020-11-28 06:03

    Note that not even the model interfaces are thread safe. The size and the content are queried with separate get methods and so there is no way of synchronizing those.

    Updating the state of the model from another thread allows for it to at least paint a situation where size is still bigger (table row is still in place), but the content is no longer there.

    Updating state of the model always in EDT avoids these.

提交回复
热议问题