When I start my GUI interfaces, what can happen if I don't use invokeLater?
- Does that mean all rest of the GUI paints/updates/etc. will be in the main thread?
- Will calling a
repaint
outside of aninvokeLater
make all subsequent calls fall into the main thread?
Basically this:
void main()
{
JFrame jmf();
setVisible(jmf);
}
------------- VS -------------
void main()
{
SwingUtilities.invokeLater(new Runnable(){
run(){
JFrame jmf();
setVisible(jmf);
}
}
});
NOTE: In cases with small GUI, I if I don't put the invokeLater
it seems to work fine. And in fact the application doesn't terminate although the last line of the main
is executed.
I have read quite a few articles on why we should use it pertaining to the fact that Swing is not thread safe (it is single threaded and so on), but I really didn't read the repercussions of not calling invokeLater
(partially because of my limited knowledge in Threads)