Is Java capable of creating more than one EDT at a time?
I am experimenting with customizing EDT and how it works when updating the contents of a βheavy dutyβ panel with a potentially dozen panels built in and hundreds of components. I am currently
public void run() { SwingUtilities.invokeLater(new Runnable() { public void run() { panel.update(); } }); }
I looked at the following posts:
Occupancy Flow Measurement of Event Dispatch
How does the event dispatch thread work?
Discussion of Java-Dispatching Thread Events
http://en.wiki2.org/wiki/Event_dispatching_thread
etc.
I understand that if there are, say, a dozen events that one EDT should handle, Java already has an internal planning mechanism for grouping / prioritizing these events.
According to http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html
"This is necessary because most Swing object methods are not "thread safe": invoking them from multiple threads risks thread interference or memory consistency errors."
So what if I create a second EDT with a new thread (new Runnable () {...}. Start () below?
Will java automatically merge two EDTs back into one, fearing thread safety?
new Thread(new Runnable() { public void run() { SwingUtilities.invokeLater(new Runnable() { public void run() { panel.update(); } }); } }).start();
source share