PrintWriter is waiting for flash ()

I am writing a multi-threaded socket server. I use nio ServerSocketChannelto receive connections. Then Ii'm reading and writing (in separate streams) to socketChannelusing bufferedreaderand fingerprint. The problem is that it PrintWriterblocks and waits for the command flush(). It blocks the stream until data bufferedreaderis received.

+3
source share
2 answers

This means that the receiver is slow. How block I / O works. If you want non-blocking I / O, you are already part of this path since you are already using NIO. Although I really see no reason to use NIO in lock mode at all.

+2
source

@EJP, -. , , . ( ) , , .


? .

, , . , , . .

, " ", . , . , .


, .

  • , .

  • / , .

  • JVM. , Java PipeInputStream/PipeOutputStream . ( , , ..)

  • , JVM, , Buffered* , , /.

0

Source: https://habr.com/ru/post/1793454/


All Articles