Class ISPT

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ISPT
    extends java.lang.Thread
    ISPT - Documentation.

    ISPT: InputStream Printing Thread

    This class is used to asynchronously print String data from both Terminal Standard-Output and also Terminal Standard-Error to an output java.lang.Appendable. All it is is an extension of Java class Thread that receives an instance of InputStream to its constructor, and, when started as a Thread, prints the contents of the InputStream to a user provided Appendable.

    Internally, this class simply builds a java.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 one InputStream to a user provided output Appendable mechanism - asynchronously. The need for 'asynchronous' printing arose out of using the class java.lang.Process which has the behaviour of sending output to two different text-streams (Standard-Out and Standard-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.



    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor
      ISPT​(InputStream inputStream, Appendable appendable, Completed completed, String name)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ISPT

        public ISPT​(java.io.InputStream inputStream,
                    java.lang.Appendable appendable,
                    Completed completed,
                    java.lang.String name)
        This shall build a Thread that asynchronously prints text read from an InputStream directly to the provided 'Appendable'.
        Parameters:
        inputStream - The InputStream to be read.
        appendable - Where the read text shall be sent
        completed - This class only works in coordination with the class 'Completed'. This class is used to allow the user to 'wait' until this independent Thread has run to completion.
        name - The Thread that is created (as 'this' inherits class 'Thread', shall have the 'name' that is provided to this parameter.
    • Method Detail

      • numCharsRead

        public int numCharsRead()
        This returns a count on the number of characters that have been read from the InputStream
        Returns:
        Number of characters that have been read from the InputStream
        Code:
        Exact Method Body:
        1
         return ispr.numCharsRead();