T
- the result type of execution execute
public class TimeoutCommand<T>
extends java.lang.Object
Constructor and Description |
---|
TimeoutCommand() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Gracefully destroy opened resources.
|
T |
execute(java.util.concurrent.Callable<T> task,
long timeout,
java.util.concurrent.TimeUnit unit)
Executes a
Callable interface with a timeout delay. |
public T execute(java.util.concurrent.Callable<T> task, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.Exception
Callable
interface with a timeout delay.
Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result, if available.task
- instructions to be executedtimeout
- the maximum time to waitunit
- the time unit of the timeout argumentjava.util.concurrent.TimeoutException
- if the operation is not executed within the configured delay.java.lang.Exception
public void destroy()