Package org.smtlib

Class SolverProcess.StreamGobbler

java.lang.Object
java.lang.Thread
org.smtlib.SolverProcess.StreamGobbler
All Implemented Interfaces:
Runnable
Enclosing class:
SolverProcess

public static class SolverProcess.StreamGobbler extends Thread
Continuously drains one of the process's output streams (stdout or stderr) on a dedicated thread, so that a solver writing a large amount of text to one stream can never be blocked by the other stream's OS pipe buffer filling up while this process is busy reading elsewhere -- reading stdout and stderr sequentially in a single thread cannot make that guarantee. Complete chunks of text are handed off to the consumer through a BlockingQueue, which is what supplies the actual thread-safety here: only this thread ever touches the in-progress StringBuilder, and only complete, immutable Strings cross to another thread, via a queue implementation that already provides the necessary locking and visibility guarantees. No manual synchronized/wait/notify is needed.