This page tracks which blocking operations release the underlying thread to do other work. It's for reference purposes. Developers using the Java APIs should not be concerned with any of the details here, it's transparent and will be unspecified as to which APIs are scheduling points.
The following blocking operations are "virtual thread friendly". When not pinned, they will release the underlying carrier thread to do other work when the operation blocks.
|java.lang.Thread||sleep, join||join to wait for a virtual thread to terminate|
|java.util.concurrent||All blocking operations|
|java.net.Socket||connect, read, write||Socket constructors with a host name parameter may need to do a lookup with InetAddress, see below|
|java.net.DatagramSocket/MulticastSocket||receive||connect, disconnect and send do not block|
|java.nio.channels.SocketChannel||connect, read, write|
connect, disconnect, send, and write do not block
|Console streams (System.in, out, err)||read, write, printf||Linux/macOS only|
The following blocking operations use the ForkJoinPool.ManagedBlocker mechanism when invoked from a virtual thread. Parallelism is temporarily expanded until the blocking operation completes.
|java.io.File||All file I/O operations|
|java.io.FileInputStream||open, read, skip|
|java.io.RandomAccessFile||open, read, write, seek|
|java.net.InetAddress||All lookup operations||InetAddress SPI in the works that will allow deploying a virtual thread friendly name resolver|
|java.nio.channels.Selector||All blocking selection operations|
|java.nio.channels.FileChannel||read, write, lock, truncate, force, transferTo|
|java.nio.file||All file I/O operations|
The following are some of the blocking operations that use the ForkJoinPool.ManagedBocker mechanism by way of the operations in the previous table.
|java.lang.Thread||join||join to wait for a kernel thread to terminate|
|java.lang.Process||All operations on the input/output/error streams|
|Console streams (System.in, out, err)||read, write, printf||Windows only|
|java.io.Console||All read, format, printf operations|