public void close() throws IOException { try { lock.getBusyFlag(); reslen = 0; // Clear Buffer EOF = true; // Mark End Of File empty.cvBroadcast(); // Alert all Threads full.cvBroadcast(); } finally { lock.freeBusyFlag(); } }
public void run() { try { while (true) { int c = in.read(); try { lock.getBusyFlag(); if ((c == -1) || (EOF)) { EOF = true; // Mark End Of File in.close(); // Close Input Source return; // End IO Thread } else { putChar((byte) c); // Store the byte read } if (EOF) { in.close(); // Close Input Source return; // End IO Thread } } finally { lock.freeBusyFlag(); } } } catch (IOException e) { IOError = e; // Store Exception return; } finally { try { lock.getBusyFlag(); empty.cvBroadcast(); // Alert all Threads } finally { lock.freeBusyFlag(); } } }