コード例 #1
0
 public int read() throws IOException {
   try {
     lock.getBusyFlag();
     while (reslen == 0) {
       try {
         if (EOF) return (-1);
         if (IOError != null) throw IOError;
         empty.cvWait();
       } catch (InterruptedException e) {
       }
     }
     return (int) getChar();
   } finally {
     lock.freeBusyFlag();
   }
 }
コード例 #2
0
 private void putChar(byte c) {
   try {
     lock.getBusyFlag();
     while ((reslen == result.length) && (!EOF)) {
       try {
         full.cvWait();
       } catch (InterruptedException ie) {
       }
     }
     if (!EOF) {
       result[reslen++] = c;
       empty.cvSignal();
     }
   } finally {
     lock.freeBusyFlag();
   }
 }
コード例 #3
0
  public int read(byte b[], int off, int len) throws IOException {
    try {
      lock.getBusyFlag();
      while (reslen == 0) {
        try {
          if (EOF) return (-1);
          if (IOError != null) throw IOError;
          empty.cvWait();
        } catch (InterruptedException e) {
        }
      }

      int sizeread = Math.min(reslen, len);
      byte c[] = getChars(sizeread);
      System.arraycopy(c, 0, b, off, sizeread);
      return (sizeread);
    } finally {
      lock.freeBusyFlag();
    }
  }