public void write ( int b ) throws IOException { while ( true ) { lockW . lock ( ) ; try { // fail if closed checkClosed ( ) ; if ( length - availableCount . get ( ) > 0 ) { bytes [ writeCursor ] = ( byte ) b ; incWriteCursor ( 1 ) ; availableCount . incrementAndGet ( ) ; totalWritten ++ ; return ; } } finally { lockW . unlock ( ) ; } sleep ( 1 ) ; } }
Write a single byte to the buffer . Will block until the byte can be written or fail when buffer is closed .