OutputStream writeChannel ( int channel ) throws IOException { while ( os != null ) { boolean canWrite = false ; synchronized ( WRITE_LOCK ) { if ( ! isWriteLocked ) { isWriteLocked = true ; canWrite = true ; } else { try { WRITE_LOCK . wait ( 5000 ) ; } catch ( Exception e ) { } } } if ( canWrite ) { os . write ( ' ' ) ; os . write ( channel >> 8 ) ; os . write ( channel ) ; return os ; } } return null ; }
Grabs the channel for writing .