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 AtomicBoolean
Set to true when a thread is interrupted.private final AtomicReference
<ExecutionException> The firstExecutionException
that was thrown. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.boolean
Check for interruption and return interruption status.static Throwable
Get the cause of anExecutionException
.Get theExecutionException
that was thrown by a worker, or null if none.void
Interrupt all threads that share this InterruptionChecker.void
setExecutionException
(ExecutionException executionException) Set theExecutionException
that was thrown by a worker.
-
Field Details
-
interrupted
Set to true when a thread is interrupted. -
thrownExecutionException
The firstExecutionException
that was thrown.
-
-
Constructor Details
-
InterruptionChecker
public InterruptionChecker()
-
-
Method Details
-
interrupt
public void interrupt()Interrupt all threads that share this InterruptionChecker. -
setExecutionException
Set theExecutionException
that was thrown by a worker.- Parameters:
executionException
- the execution exception that was thrown
-
getExecutionException
Get theExecutionException
that was thrown by a worker, or null if none.- Returns:
- the
ExecutionException
that 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.
-