The following blocking operations are virtual thread friendly in the current prototype; these methods do not pin the carrier thread when the operation blocks.
API | Blocking Methods | Notes |
---|---|---|
java.net.Socket | connect, read, write | |
java.net.ServerSocket | accept | |
java.net.DatagramSocket/MulticastSocket | receive | |
java.nio.channels.SocketChannel | connect, read, write | socket adaptor connect, read, and write also okay |
java.nio.channels.ServerSocketChannel | accept | socket adaptor accept also okay |
java.nio.channels.DatagramChannel | read, receive | socket adaptor receive also okay |
java.nio.channels.Pipe.SourceChannel | read | |
java.nio.channels.Pipe.SinkChannel | write |
The following blocking operations pin the carrier thread when the operation blocks. These blocking operations do use the uses the ForkJoinPool.ManagedBocker mechanism (in the case of default scheduler at least) to temporarily extend to temporarily expand the parallelism until the blocking operation completes.
API | Methods | Notes||
---|---|---|---|
java.io.File | All file I/O operations | ||
java.io.FileInputStream | open, read, skip | ||
java.io.FileOutputStream | open, write | ||
java.netio.InetAddressRandomAccessFile | getByNameopen, read, getAllByNamewrite, seek | ||
java.io.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.Console | All read, format and PrintStream operations | ||
java.net.InetAddress | All lookup operations | ||
java.nio.MappedByteBuffer | force | ||
java.nio.channels.Selector | All blocking selection operations | ||
java.nio.channels.SelectorFileChannel | read, write, lock, truncate, force, transferTo | ||
java.nio.file | All file I/O operations | select | Selection 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. |
Overview
Content Tools
ThemeBuilder