0

I have a Swing application and upon updating the JTable the GUI freezes. I know updates should be done from the EDT, so I use InvokeLater for it. My application runs on many threads at once(1000), so im guessing maybe that computing time is the cause. If so, can i set a minimum cpu time for the EDT so the GUI won't freeze?

One more question, only direct changes to the GUI should be done on EDT thread or also for example an insertion to an ArrayList that is a variable in class that extends a JFrame?

Answers much appreciated.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Jhonny
  • 587
  • 1
  • 6
  • 17
  • 1
    No, you can't control the CPU time of threads, not really and not all platforms support the notion anyway. To you second class, if your UI depends on the values in the `ArrayList` in order to keep the UI up-to-date, then you should not modify the `ArrayList` out side of the context of the EDT, as the `ArrayList` itself is not thread safe and the UI may be updated at anytime, without your direct interaction, which could cause dirty updates – MadProgrammer Nov 16 '15 at 23:09
  • I ll fix that too but my primary concern now is the freeze. How could i prevent that? – Jhonny Nov 17 '15 at 00:18
  • Well it's difficult to really make any suggestion without seeing what and how you're doing it. One idea might be to reduce the number threads and use a ExecutorService to schedule tasks – MadProgrammer Nov 17 '15 at 00:28
  • Two approaches are cited [here](http://stackoverflow.com/a/33523421/230513). – trashgod Nov 17 '15 at 03:42

0 Answers0