void () { setStatus(ConnectionStatus.WAITING_FOR_CONNECTION, null); ApplicationManager.getApplication().executeOnPooledThread(() -> { addThreadToInterrupt(); try { for (int attempt = 0; attempt < MAX_CONNECTION_ATTEMPTS; attempt++) { try { open(); return; } catch (IOException e) { LOG.debug(e); } //noinspection BusyWait Thread.sleep(CONNECTION_ATTEMPT_DELAY); } setStatus(ConnectionStatus.CONNECTION_FAILED, "Cannot connect to " + (myHost != null ? myHost : "localhost") + ", the maximum number of connection attempts exceeded"); } catch (InterruptedException ignored) { } finally { removeThreadToInterrupt(); } }); }