Top Description Fields Constructors Methods
nonapi.io.github.classgraph.concurrency

public Class InterruptionChecker

extends Object
Class Inheritance
Imports
java.util.concurrent.ExecutionException, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference

Check if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception.

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
interrupted

Set to true when a thread is interrupted.

private final AtomicReference<ExecutionException>
thrownExecutionException

The first ExecutionException that was thrown.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
check()

Check if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception, and if so, throw InterruptedException.

public boolean

Returns:

true if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception.
checkAndReturn
()

Check for interruption and return interruption status.

public static Throwable

Returns:

the cause
getCause
(final Throwable
the Throwable
throwable
)

Get the cause of an ExecutionException.

public ExecutionException

Returns:

the ExecutionException that was thrown by a worker, or null if none.
getExecutionException
()

Get the ExecutionException that was thrown by a worker, or null if none.

public void
interrupt()

Interrupt all threads that share this InterruptionChecker.

public void
setExecutionException(final ExecutionException
the execution exception that was thrown
executionException
)

Set the ExecutionException that was thrown by a worker.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

interruptedback to summary
private final AtomicBoolean interrupted

Set to true when a thread is interrupted.

thrownExecutionExceptionback to summary
private final AtomicReference<ExecutionException> thrownExecutionException

The first ExecutionException that was thrown.

Constructor Detail

InterruptionCheckerback to summary
public InterruptionChecker()

Method Detail

checkback to summary
public void check() throws InterruptedException, ExecutionException

Check if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception, and if so, throw InterruptedException.

Exceptions
InterruptedException:
If a thread has been interrupted.
ExecutionException:
if a thread has thrown an uncaught exception.
checkAndReturnback to summary
public boolean checkAndReturn()

Check for interruption and return interruption status.

Returns:boolean

true if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception.

getCauseback to summary
public static Throwable getCause(final Throwable throwable)

Get the cause of an ExecutionException.

Parameters
throwable:Throwable

the Throwable

Returns:Throwable

the cause

getExecutionExceptionback to summary
public ExecutionException getExecutionException()

Get the ExecutionException that was thrown by a worker, or null if none.

Returns:ExecutionException

the ExecutionException that was thrown by a worker, or null if none.

interruptback to summary
public void interrupt()

Interrupt all threads that share this InterruptionChecker.

setExecutionExceptionback to summary
public void setExecutionException(final ExecutionException executionException)

Set the ExecutionException that was thrown by a worker.

Parameters
executionException:ExecutionException

the execution exception that was thrown