Class InterruptionChecker
- java.lang.Object
-
- nonapi.io.github.classgraph.concurrency.InterruptionChecker
-
public class InterruptionChecker extends java.lang.ObjectCheck if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBooleaninterruptedSet to true when a thread is interrupted.private java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ExecutionException>thrownExecutionExceptionThe firstExecutionExceptionthat was thrown.
-
Constructor Summary
Constructors Constructor Description InterruptionChecker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheck()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.booleancheckAndReturn()Check for interruption and return interruption status.static java.lang.ThrowablegetCause(java.lang.Throwable throwable)Get the cause of anExecutionException.java.util.concurrent.ExecutionExceptiongetExecutionException()Get theExecutionExceptionthat was thrown by a worker, or null if none.voidinterrupt()Interrupt all threads that share this InterruptionChecker.voidsetExecutionException(java.util.concurrent.ExecutionException executionException)Set theExecutionExceptionthat was thrown by a worker.
-
-
-
Field Detail
-
interrupted
private final java.util.concurrent.atomic.AtomicBoolean interrupted
Set to true when a thread is interrupted.
-
thrownExecutionException
private final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ExecutionException> thrownExecutionException
The firstExecutionExceptionthat was thrown.
-
-
Method Detail
-
interrupt
public void interrupt()
Interrupt all threads that share this InterruptionChecker.
-
setExecutionException
public void setExecutionException(java.util.concurrent.ExecutionException executionException)
Set theExecutionExceptionthat was thrown by a worker.- Parameters:
executionException- the execution exception that was thrown
-
getExecutionException
public java.util.concurrent.ExecutionException 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
public static java.lang.Throwable getCause(java.lang.Throwable throwable)
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
public void check() throws java.lang.InterruptedException, java.util.concurrent.ExecutionExceptionCheck 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:
java.lang.InterruptedException- If a thread has been interrupted.java.util.concurrent.ExecutionException- if a thread has thrown an uncaught exception.
-
-