Class ThreadSafeCountingInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public final class ThreadSafeCountingInputStream
    extends FilterInputStream
    Copied from Guava's CountingInputStream. Changed the state variables to be volatile, to allow the caller of the getCount() to be from a different thread than the reader thread. So it's thread safe in the sense that we allow a single reader thread, and multiple querying threads calling getCount().
    Author:
    Eyal Schneider