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

Compare with Current View Page History

« Previous Version 37 Next »

The following blocking operations are virtual thread friendly; these methods "release" the underlying carrier thread when the operation blocks.

APIMethod(s)Notes
java.lang.Threadsleep, joinjoin to wait for a virtual thread to terminate
java.lang.ProcesswaitForLinux/macOS only
java.util.concurrentAll blocking operations
java.net.Socketconnect, read, writeSocket constructors with a host name parameter may need to do a lookup with InetAddress, see below
java.net.ServerSocketaccept
java.net.DatagramSocket/MulticastSocketreceiveconnect, disconnect and send do not block
java.nio.channels.SocketChannelconnect, read, write
java.nio.channels.ServerSocketChannelaccept
java.nio.channels.DatagramChannelread, receive

connect, disconnect, send, and write do not block 

java.nio.channels.Pipe.SourceChannelread
java.nio.channels.Pipe.SinkChannelwrite
Console streams (System.in, out, err)read, write, printfLinux/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.

APIMethod(s)Notes
java.lang.Objectwait
java.lang.ProcesswaitForWindows only
java.io.FileAll file I/O operations
java.io.FileInputStreamopen, read, skip
java.io.FileOutputStreamopen, write
java.io.RandomAccessFileopen, read, write, seek
java.net.InetAddressAll lookup operationsInetAddress SPI in the works that will allow deploying a virtual thread friendly name resolver
java.nio.MappedByteBufferforce
java.nio.channels.SelectorAll blocking selection operations
java.nio.channels.FileChannelread, write, lock, truncate, force, transferTo
java.nio.fileAll 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.

APIMethod(s)Notes
java.lang.Threadjoinjoin to wait for a kernel thread to terminate
java.lang.ProcessAll operations on the input/output/error streams
Console streams (System.in, out, err)read, write, printfWindows only
java.io.ConsoleAll read, format, printf operations



  • No labels