code: InputStream readChannel(int channel)
          throws IOException
      {
          while (!isClosed) {
              if (inputReady[channel]) {
                  inputReady[channel] = false;
                  return is;
              }
  
              boolean canRead = false;
              synchronized (READ_LOCK) {
                  if (!isReadLocked) {
                      isReadLocked = true;
                      canRead = true;
                  }
                  else {
                      try {
                          READ_LOCK.wait(5000);
                      } catch (Exception e) {
                      }
                  }
              }
  
              if (canRead) {
                  try {
                      readData();
                  } catch (IOException e) {
                      close();
                  }
              }
          }
  
          return null;
      }
docs: Reads data from a channel.
  
  @param channel the channel
  
  @return true if the channel is valid.