Package org.apfloat.samples
Class BackgroundOperation<T>
java.lang.Object
org.apfloat.samples.BackgroundOperation<T>
Class for running an
Operation
in the background in a separate thread.
The operation is executed using the ExecutorService retrieved from
ApfloatContext.getExecutorService()
.- Version:
- 1.14.0
- Author:
- Mikko Tommila
-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundOperation
(Operation<T> operation) Runs an operation in the background in a separate thread. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancel the operation by interrupting the thread executing it.Get the result of the operation.boolean
Check if the operation has been completed.
-
Constructor Details
-
BackgroundOperation
-
-
Method Details
-
isFinished
public boolean isFinished()Check if the operation has been completed.- Returns:
true
if the execution of the operation has been completed, otherwisefalse
.
-
cancel
public void cancel()Cancel the operation by interrupting the thread executing it.- Since:
- 1.14.0
-
getResult
Get the result of the operation. This method blocks until the operation has been completed.- Returns:
- Result of the operation.
- Throws:
RuntimeException
- If an exception was thrown by the executed operation.
-