public abstract class InterruptableAction<T> extends java.lang.Object
The class allowing to execute some action, interruptable via standard Java technique,
in terms of some
In other words, it is a bridge between
InterruptionContext and standard interruption technique
based on thread.interrupt() and Thread.interrupted() calls.
|Modifier||Constructor and Description|
Creates an instance of this class with the given interruption context.
|Modifier and Type||Method and Description|
This method performs some action or throws InterruptedException in a case when the current thread is interrupted via thread.interrupt() call.
protected InterruptableAction(InterruptionContext context)
context- an interruption context that will be used for interruption of the action.
java.lang.NullPointerException- if the argument is null.
public T doInterruptibly() throws InterruptionException
run()method and returns its result.
If the interruption context requests an interruption
interruption event occurs),
the current thread, executing
run() method, is interrupted
by its interrupt() method.
As a result, the
run() method should stop and
throw the standard InterruptedException.
This method catches it and translates into
InterruptionException with the corresponding cause;
InterruptionException is thrown.
So, this method can be interrupted by both ways: by the standard
thread.interrupt() call and by interruption mechanism
provided by the
public abstract T run() throws java.lang.InterruptedException
java.lang.InterruptedException- if the current thread is interrupted via thread.interrupt() call.