void () { final DebugProcessListener listener = new DebugProcessAdapterImpl() { //executed in manager thread @Override public void processDetached(DebugProcessImpl process, boolean closedByUser) { if (!myAutoRestart || closedByUser || myClosedByUser.get()) { process.removeDebugProcessListener(this); notifyProcessDetached(); } else { process.reattach(process.getSession().getDebugEnvironment()); } } }; DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this); debugProcess.addDebugProcessListener(listener); try { super.startNotify(); } finally { // in case we added our listener too late, we may have lost processDetached notification, // so check here if process is detached if (debugProcess.isDetached()) { debugProcess.removeDebugProcessListener(listener); notifyProcessDetached(); } } }