closed = true; notifyAll();
try { while(!empty() && !closed) wait(); if (!empty()) throw new IOException("Closing non empty stream."); closed = true; notifyAll(); } catch (InterruptedException e) { throw new IOException( "Close OutputStream operation interrupted."+ e); }
    public synchronized void close() throws IOException {        closed = true;        notifyAll();    }