Top Description Fields Constructors Methods
jdk.internal.misc

public Class Blocker

extends Object
Class Inheritance
Imports
jdk.internal.access.JavaLangAccess, .SharedSecrets

Defines static methods to mark the beginning and end of a possibly blocking operation. The methods are intended to be used with try-finally as follows:
boolean attempted = Blocker.begin(); try { // blocking operation } finally { Blocker.end(attempted); }
boolean attempted = Blocker.begin();
try {
    // blocking operation
} finally {
    Blocker.end(attempted);
}
If invoked from a virtual thread and the underlying carrier thread is a CarrierThread then the code in the block runs as if it were in run in ForkJoinPool.ManagedBlocker. This means the pool can be expanded to support additional parallelism during the blocking operation.

Field Summary

Modifier and TypeField and Description
private static final JavaLangAccess

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if tryCompensate attempted
begin
()

Marks the beginning of a blocking operation.

public static boolean

Returns:

true if tryCompensate attempted
begin
(boolean
true if the operation may block, otherwise false
blocking
)

Marks the beginning of a possibly blocking operation.

private static Thread
public static void
end(boolean
if tryCompensate attempted
attempted
)

Marks the end of an operation that may have blocked.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JLAback to summary
private static final JavaLangAccess JLA

Constructor Detail

Blockerback to summary
private Blocker()

Method Detail

beginback to summary
public static boolean begin()

Marks the beginning of a blocking operation.

Returns:boolean

true if tryCompensate attempted

beginback to summary
public static boolean begin(boolean blocking)

Marks the beginning of a possibly blocking operation.

Parameters
blocking:boolean

true if the operation may block, otherwise false

Returns:boolean

true if tryCompensate attempted

currentCarrierThreadback to summary
private static Thread currentCarrierThread()
endback to summary
public static void end(boolean attempted)

Marks the end of an operation that may have blocked.

Parameters
attempted:boolean

if tryCompensate attempted