private void doTask() { Runnable task; while ((task = ssle.getDelegatedTask()) != null) { task.run(); } eventQueue.invokeLater(() -> { hs = ssle.getHandshakeStatus(); handshake(); }); }
/** * Executes and waits for a command in main thread.<p> * <b>MUST be called outside main thread.</b> */ public default void invokeAndWait(Runnable runnable) { CountDownLatch latch = new CountDownLatch(1); invokeLater(() -> { runnable.run(); latch.countDown(); }); try { latch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }