Suppose that a method I own is sometimes called on the Event Dispatch Thread and is sometimes not. Now suppose some of the code in that method I want to have called on a thread other than the Event Dispatch Thread.
Is there a way to run some code on a thread other than the EDT at this point?
I tried this:
if (SwingUtilities.isEventDispatchThread()) {
new Runnable() {
@Override
public void run() {
myMethod();
}
}.run();
} else {
myMethod();
}
But myMethod() ended up running on the EDT even when I created a new Runnable.
Is there a way to run myMethod() on a thread other than the EDT at this point?