Just a musing about some repetitive code I have:
Runnable run = new Runnable() {
@Override
public void run() {
// Some EDT code
}
};
if (!EventQueue.isDispatchThread()) {
SwingUtilities.invokeAndWait(run);
} else {
run.run();
}
It's not terribly annoying, but it seems like there would be some proprietary function that checks this for you, although I haven't found it.
Excluding Substance Look and Feel I never needed to use
invokeAndWait
or testing forisDispatchThread / isEventDispatchThread
,Substance Look and Feel required in some special cases usage of
invokeAndWait
forJTable
,JTree
,SwingX's TreeTable
, really not important in this casedelay 30seconds is required for "expiring of EDT" then you can creating n_Threads, each of then can alive EDT, simple, without special effort, another limit could be Latency from Native OS
output
from
you can do everything, changing orders, methods, freezing by
Thread.sleep(int)
, in all cases is possible to alive EDT in the assumed moment, nothing shadowed, any miracles, wrong code that calling to the Heavens instead of to the EDTThere isn't.
Consider to use
http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html
or
http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
instead.