Is Java capable of creating more than one EDT at a time?
I'm experimenting with setting up EDT and how it works in updating the content of a "heavy duty" panel with potentially a dozen of panels embedded inside and with hundreds of components altogether. Currently I have
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
panel.update();
}
});
}
I've looked at the following posts:
Measuring "busyness" of the event dispatching thread
How does the event dispatch thread work?
Java Event-Dispatching Thread explanation
http://en.wiki2.org/wiki/Event_dispatching_thread
and so forth.
I sort of understand that if there are, say a dozen of events, that an single EDT has to handle, Java already has an internal scheduling mechanism to group/prioritize 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 2nd EDT with new Thread(new Runnable() { ... }.start() below?
Will java automatically merge the two EDTs back to one for fear of thread safety?
new Thread(new Runnable() {
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
panel.update();
}
});
}
}).start();