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

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

Blocking

  • Created by Alan Bateman, last modified on Oct 31, 2020

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.ManagedBocker mechanism when invoked from a virtual thread. Parallelism is temporarily extended 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.23
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 208, "requestCorrelationId": "97fe437022eb59da"}