• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. Loom
  4. Blocking Operations

Blocking Operations

  • Created by Alan Bateman, last modified on Nov 01, 2020

This page is for reference purposes.


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.

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



Overview
Content Tools
ThemeBuilder
  • No labels

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.21
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 230, "requestCorrelationId": "dffe2caffafde736"}