Should I allocate/create swing elements into EDT?

前端 未结 2 1925
萌比男神i
萌比男神i 2021-01-24 12:40

Should I create swing elements into EDT?

I got the concurrency problems with editing non thread-safe graphics elements, but I\'m creating them, they aren\'t shown yet, a

2条回答
  •  面向向阳花
    2021-01-24 13:00

    In the Swing separable model architecture, a view component listens to its model. Because a view may respond arbitrarily to events generated by model updates, the corresponding model must also be updated on the EDT. You can mitigate latency via one of two basic approaches:

    • Use EventQueue.invokeLater() from a separate thread, as shown here.

    • Use SwingWorker to obtain the additional benefits enumerated here.

提交回复
热议问题