void () { flushStdOutBuffer(); List<OutputChunk> stderrChunksToFlush; synchronized (myStdErrChunks) { stderrChunksToFlush = new ArrayList<>(myStdErrChunks); myStdErrChunks.clear(); } onChunksAvailable(stderrChunksToFlush, false); List<OutputChunk> systemChunksToFlush; synchronized (mySystemChunks) { systemChunksToFlush = new ArrayList<>(mySystemChunks); mySystemChunks.clear(); } onChunksAvailable(systemChunksToFlush, false); }