Without considering the look and feel of the substance, I never had to use invokeAndWait or testing for isDispatchThread / isEventDispatchThread ,
The look of the substance and the feeling required in some special cases, the use of invokeAndWait for JTable , JTree , SwingX TreeTable , really does not matter in this case
A delay of 30 seconds is required for the "expiration of the EDT", then you can create n_Threads, each of which can be a live EDT, simple, without much effort, another limit can be a delay from the native OS
Exit
run: Time at : 00:00:45 There isn't Live EventQueue.isDispatchThread, why any reason for that There isn't Live SwingUtilities.isEventDispatchThread, why any reason for that Time at : 00:00:45 EventQueue.isDispatchThread SwingUtilities.isEventDispatchThread Time at : 00:00:45 EventQueue.isDispatchThread SwingUtilities.isEventDispatchThread Time at : 00:01:15 There isn't Live EventQueue.isDispatchThread, why any reason for that There isn't Live SwingUtilities.isEventDispatchThread, why any reason for that Push a new event to EDT Time at : 00:01:45 EventQueue.isDispatchThread SwingUtilities.isEventDispatchThread Time at : 00:02:15 There isn't Live EventQueue.isDispatchThread, why any reason for that There isn't Live SwingUtilities.isEventDispatchThread, why any reason for that Time at : 00:02:45 There isn't Live EventQueue.isDispatchThread, why any reason for that There isn't Live SwingUtilities.isEventDispatchThread, why any reason for that Push a new event to EDT Time at : 00:03:15 EventQueue.isDispatchThread SwingUtilities.isEventDispatchThread Time at : 00:03:45 There isn't Live EventQueue.isDispatchThread, why any reason for that There isn't Live SwingUtilities.isEventDispatchThread, why any reason for that Time at : 00:04:15 There isn't Live EventQueue.isDispatchThread, why any reason for that There isn't Live SwingUtilities.isEventDispatchThread, why any reason for that Push a new event to EDT Time at : 00:04:45 EventQueue.isDispatchThread SwingUtilities.isEventDispatchThread Terminating this madness BUILD SUCCESSFUL (total time: 4 minutes 31 seconds)
from
import java.awt.EventQueue; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.*; public class IsThereEDT { private ScheduledExecutorService scheduler; private AccurateScheduledRunnable periodic; private ScheduledFuture<?> periodicMonitor; private int taskPeriod = 30; private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); private Date dateRun; private JFrame frame1 = new JFrame("Frame 1"); public IsThereEDT() { scheduler = Executors.newSingleThreadScheduledExecutor(); periodic = new AccurateScheduledRunnable() { private final int ALLOWED_TARDINESS = 200; private int countRun = 0; private int countCalled = 0; private int maxCalled = 10; @Override public void run() { countCalled++; if (countCalled < maxCalled) { if (countCalled % 3 == 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { System.out.println("Push a new event to EDT"); frame1.repaint(); isThereReallyEDT(); } }); } else { if (this.getExecutionTime() < ALLOWED_TARDINESS) { countRun++; isThereReallyEDT();
you can do everything by changing the order, methods, freezing Thread.sleep(int) , in all cases it is possible to animate EDT at the expected moment, not to obscure anything, no miracles, wrong code calling Heaven, not EDT