@Override
    public void run() {
      SecureRandom rand = new SecureRandom();
      for (int j = 0; j < numberOfReads; j++) {
        int pos = rand.nextInt(plaintextSize);
        int size = rand.nextInt(plaintextSize / 10) + 1;
        ByteBuffer plaintext = ByteBuffer.allocate(size);
        try {
          channel.position(pos);
          int read = channel.read(plaintext);
          if (read == -1) {
            continue;
          }
        } catch (IOException ex) {
          getUncaughtExceptionHandler().uncaughtException(this, ex);
        }
        // We expect that both channel.position(pos) and
        // channel.read() are atomic, but we cannot assume that read actually reads the
        // plaintext at position pos. The only assumption that can be made is that the plaintext
        // is a continuous part of the plaintext.
        for (int i = 1; i < plaintext.position(); i++) {
          if (((plaintext.get(i - 1) + 1) & 0xff) != (plaintext.get(i) & 0xff)) {
            fail(
                "Plaintext is not continuous at position:"
                    + (pos + i)
                    + " size:"
                    + plaintext.position()
                    + " start:"
                    + pos
                    + "\nbytes:"
                    + Hex.encode(plaintext.array()));
          }
        }
      }
    }
Read the plaintext from the channel. This implementation assumes that the channel is blocking
and throws an AssertionError if an attempt to read plaintext from the channel is incomplete.
java_src/src/test/java/com/google/crypto/tink/subtle/StreamingAeadThreadSafetyTest.java