protected void checkNotifyEndDownstream() { if (!stillWorking() && !isCompleted()) { if (downstream != null) { downstream.endOfUpstream(); } done(); // else this is the end of the line completed = true; } }
protected void checkNotifyEndDownstream() { if (!stillWorking() && !isCompleted()) { synchronized (this) { // Only allow a single thread to notify that we've ended our stream as well as calling // done() // stillWorking(), once false cannot again return true so no need to check if (!isCompleted()) { if (downstream != null) { downstream.endOfUpstream(); } done(); completed = true; } } } }