The following blocking operations are fiber friendly, meaning the fiber will park without pinning the carrier thread when the operation blocks.
API | Methods | Notes |
---|---|---|
java.net.Socket | read, write, close | Relies on JEP 353 |
java.net.ServerSocket | accept, close | |
java.nio.channels.SocketChannel | read, write, close | read, write, and close on the socket adaptor obtained via SocketChannel::socket also okay |
java.nio.channels.ServerSocketChannel | accept, close | accept and close on the socket adpator obtained via ServerSocketChannel::socket also okay |
java.nio.channels.DatagramChannel | read, receive, close | write/send do not block |
java.nio.channels.Pipe.SourceChannel | read, close | |
java.nio.channels.Pipe.SinkChannel | write, close |
The following blocking operations are not yet fiber friendly; these methods may pin the carrier thread when the socket is not ready for I/O.
API | Methods | Notes |
---|---|---|
java.net.DatagramSocket | receive | Need to investigate if receive can be done without synchronizing on the DatagramPacket (unspecified but long standing behavior) |
Thread.interrupt | If a thread is blocked in an I/O operation on an InterruptibleChannel then the channel is closed. The locking to support this is not yet fiber friendly so Thread.interrupt may pin the carrier thread while waiting for the blocking operations on the channel to abort. |
Overview
Content Tools
ThemeBuilder