Class InterruptionChecker
java.lang.Object
nonapi.io.github.classgraph.concurrency.InterruptionChecker
Check if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or
has thrown an exception.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanSet to true when a thread is interrupted.private final AtomicReference<ExecutionException> The firstExecutionExceptionthat was thrown. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheck()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.booleanCheck for interruption and return interruption status.static ThrowableGet the cause of anExecutionException.Get theExecutionExceptionthat was thrown by a worker, or null if none.voidInterrupt all threads that share this InterruptionChecker.voidsetExecutionException(ExecutionException executionException) Set theExecutionExceptionthat was thrown by a worker.
-
Field Details
-
interrupted
Set to true when a thread is interrupted. -
thrownExecutionException
The firstExecutionExceptionthat was thrown.
-
-
Constructor Details
-
InterruptionChecker
public InterruptionChecker()
-
-
Method Details
-
interrupt
public void interrupt()Interrupt all threads that share this InterruptionChecker. -
setExecutionException
Set theExecutionExceptionthat was thrown by a worker.- Parameters:
executionException- the execution exception that was thrown
-
getExecutionException
Get theExecutionExceptionthat was thrown by a worker, or null if none.- Returns:
- the
ExecutionExceptionthat was thrown by a worker, or null if none.
-
getCause
Get the cause of anExecutionException.- Parameters:
throwable- the Throwable- Returns:
- the cause
-
checkAndReturn
public boolean checkAndReturn()Check for interruption and return interruption status.- Returns:
- true if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception.
-
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.- Throws:
InterruptedException- If a thread has been interrupted.ExecutionException- if a thread has thrown an uncaught exception.
-