I have read a number of articles on the internet about when something should run in the EDT, and when it shouldn't. But I'm still not sure I understand, so I'd like to ask a few question about this:
What pieces of code are going to run by default inside the EDT?
What pieces of code are going to be run be default outside the EDT?
When should I use InvokeLater() so something that by default would run outside the EDT, will run inside it?
When should I prevent a piece of code from running (by default) inside the EDT, by creating a new thread and putting that code inside it?
Thanks
First of all thank you so much for editing and formatting your question very well. It helps a lot when answering your question.
Also i have to admit i am not 100% sure about my answers, so guys: feel free to correct me if i am wrong.
Everything which changes your graphical user interface.
Not quite sure about that.
If you need to update your gui with the time intensive calculations. For example if you want to show the numbers from 0to 100000000 in a JLabel.
Everything which would block your gui from user interaction because it takes a lot of time, for example some calculations with a lot of datasets.. But you need to make sure to access values only from one thread or to synchronize the threads with
volatile
andsynchronize
...