Package Torello.Java.Additional
Class ISPT
- java.lang.Object
-
- java.lang.Thread
-
- Torello.Java.Additional.ISPT
-
- All Implemented Interfaces:
java.lang.Runnable
public class ISPT extends java.lang.Thread
A helper class performingThread
management for classOSResponse
.
ISPT: InputStream Printing ThreadHelper Class for Torello.Java.OSCommands
This class functions in a support role to bothOSCommands
andOSResponse
. These, in turn, are the abstract parent-class and also a helper-support class for Operating-System Process-Invocation classes:Shell
,MSDOS
andGSUTIL
).
If the methods in this class do not appear to be 'generally applicable utilities' that is because they are specifically tailored to reading Process-Output (Standard-Out & Standard-Error) from Operating System calls.
The two helpers used by theOSCommands
Suite of Tools are:Completed
andISPT
. These two classes do nothing more than streamline the multi-threaded reader code for reading from ajava.lang.Process
Object as it executes an Operating-System call.
This class is used to asynchronously printString
data from bothTerminal Standard-Output
and alsoTerminal Standard-Error
to an outputjava.lang.Appendable
. All it is is an extension of Javaclass Thread
that receives an instance ofInputStream
to its constructor, and, when started as aThread
, prints the contents of theInputStream
to a user providedAppendable
.
Internally, this class simply builds ajava.lang.Runnable
that will execute when the'this' Thread's Thread.start()
method is invoked. This class was designed for use with the'Completed'
thread-monitor system for printing output from oneInputStream
to a user provided outputAppendable
mechanism - asynchronously. The need for 'asynchronous' printing arose out of using theclass java.lang.Process
which has the behaviour of sending output to two different text-streams (Standard-Out
andStandard-Error
) at the same time. Though is usually not a problem, depending upon which O/S the JVM is running, thread-freezing may occur where the entire JVM halts because one of the streams isn't being serviced. The only way to prevent such problems is to use asynchronously print monitoring.
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/ISPT.java
- Open New Browser-Tab: Torello/Java/Additional/ISPT.java
-
-
Method Summary
Retrieve the Number of chars that Were Read Modifier and Type Method int
numCharsRead()
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
ISPT
public ISPT(java.io.InputStream inputStream, java.lang.Appendable appendable, Completed completed, java.lang.String name)
This shall build aThread
that asynchronously prints text read from anInputStream
directly to the provided'Appendable'
.- Parameters:
inputStream
- TheInputStream
to be read.appendable
- Where the read text shall be sentcompleted
- This class only works in coordination with theclass 'Completed'
. This class is used to allow the user to'wait'
until this independentThread
has run to completion.name
- Since this class (ISPT
) inherits fromclass Thread
), it has a'name'
field. AllThread's
have names. Thename
of the thisThread
will be set to the value provided to this parameter.
-
-
Method Detail
-
numCharsRead
public int numCharsRead()
This returns a count on the number of characters that have been read from theInputStream
- Returns:
- Number of characters that have been read from the
InputStream
- Code:
- Exact Method Body:
return this.ispr.numCharsRead();
-
-