Channel (UUID processId) { Channel channel = null; synchronized (myConnections) { channel = myConnections.get(processId); debug(channel, ch-> "lookupChannel: channel for " + processId + " is " + ch); while (channel == null) { if (!myRunningProcesses.containsKey(processId)) { debug(()-> "lookupChannel: no process for " + processId); break; // the process is already gone } try { myConnections.wait(300L); } catch (InterruptedException ignored) { } channel = myConnections.get(processId); debug(channel, ch-> "lookupChannel: after wait channel for " + processId + " is " + ch); } } return channel; }