void () { Application app = ApplicationManager.getApplication(); app.invokeAndWait(() -> { for (int i = 0; i < 20; i++) { AtomicBoolean executed = new AtomicBoolean(); app.executeOnPooledThread(() -> app.invokeLater(EmptyRunnable.INSTANCE)); app.invokeLater(() -> executed.set(true)); UIUtil.dispatchAllInvocationEvents(); assertTrue(executed.get()); } }); }