Thread jobThreadLocal
submits the job (Process p=Runtime.getRuntime().exec(command);)
creates and starts new thread writeThread of type
writeStdout
Thread writeStdout
opens InputDataStream piped to the process standard output
instantiates BufferedReader connected to the InputDataStream
reads standard output line after line, and puts it into
outputLine
array maintained by submitLocally by calling its method
setOLine. While setting i-th element of outputLine it
also sets (i+1)-th element to "wait" and i-th element of
waitForRead array to "true". The size of outputLine
is 20, and the output lines are stored in the round robin fashion.
If an element waitForRead is "true", it means that the front
end client have not read it, so it cannot be overwritten. If this
happens (the producer is faster than the consumer), the tread
sleeps untill the client change the value to "false". The
oposite case, when the client is faster than the producer, is
handled by setting the value of the line to be read to "wait".
The client thread blocks until the writeStdout overwrites
that value by a newly read line from the standard output.