void () { if (myProject == null) { myProcessHandler.removeProcessListener(myListener); return; } ApplicationManager.getApplication().executeOnPooledThread(() -> { if (myProcessHandler.isProcessTerminated() || myProcessHandler.isProcessTerminating()) return; List<ThreadState> threadStates = null; final long start = System.currentTimeMillis(); while ((System.currentTimeMillis() - start) < 1000) { String stdout = myListener.getOutput().getStdout(); threadStates = ThreadDumpParser.parse(stdout); if (threadStates.isEmpty()) { TimeoutUtil.sleep(50); threadStates = null; continue; } break; } myProcessHandler.removeProcessListener(myListener); if (threadStates != null && !threadStates.isEmpty()) { showThreadDump(myListener.getOutput().getStdout(), threadStates, myProject); } }); }