If someone has a SocketChannel sc then one way to obtain input/output streams is via the Socket adaptor, i.e. sc.socket().getXXXStream. Another way is with Channels.newXXXStream(sc) factory methods.
A long standing limitation (that dates from the original JSR-51 and Java 1.4) is that the input/output streams returned by the Channels.newXXXStream methods must synchronize on the channel's blockingLock() to prevent the channel from being configured non-blocking. There is one "blocking lock" per SelectableChannel so problematic when the SelectableChannel is also a ByteChannel as it prevents a thread from writing while another is blocked in read (and vice versa).
More background on this issue can be found inJDK-4509080. The input/output streams for the Socket adaptor had the same limitation prior to changes in JDK 13 and JDK-8222774. The issue with the streams returned by Channels.newXXXStream resurfaced recently as part of side discussion of JDK-8278268.
A long standing limitation (that dates from the original JSR-51 and Java 1.4) is that the input/output streams returned by the Channels.newXXXStream methods must synchronize on the channel's blockingLock() to prevent the channel from being configured non-blocking. There is one "blocking lock" per SelectableChannel so problematic when the SelectableChannel is also a ByteChannel as it prevents a thread from writing while another is blocked in read (and vice versa).
More background on this issue can be found in