You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Next »

The following blocking operations are virtual thread friendly in the current prototype; these methods do not pin the carrier thread when the operation blocks.

APIBlocking MethodsNotes
java.net.Socketconnect, read, write
java.net.ServerSocketaccept
java.net.DatagramSocket/MulticastSocketreceive



java.nio.channels.SocketChannelconnect, read, writesocket adaptor connect, read, and write also okay
java.nio.channels.ServerSocketChannelacceptsocket adaptor accept also okay
java.nio.channels.DatagramChannelread, receive

socket adaptor receive also okay

java.nio.channels.Pipe.SourceChannelread
java.nio.channels.Pipe.SinkChannelwrite


The following blocking operations pin the carrier thread when the operation blocks. These blocking operations do use the ForkJoinPool.ManagedBocker mechanism (in the case of default scheduler at least) to temporarily extend the parallelism until the blocking operation completes.

APIMethodsNotes
java.net.InetAddressgetByName, getAllByName, ..

An alternative name service implementation for InetAddress has been prototyped in the sandbox (aefimov-dns-client-branch) is virtual thread friendly. TBD if this will be proposed as a JEP. A service provider interface will be introduced to make it possible to deploy name service implementations that do not pin the carrier thread during lookups.

java.nio.channels.SelectorselectSelection operations are specified to synchronize on the selector and the selected-key set. May not be a concern as code using virtual thread should not need to use non-blocking I/O and Selectors. The number of Selectors is typically small anyway.
  • No labels