public final class TimeLimiter
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TimeLimiter.UncheckedTimeoutException
Unchecked version of
TimeoutException. |
| Constructor and Description |
|---|
TimeLimiter(java.util.concurrent.ExecutorService executor)
Create a new TimeLimiter that will use the provided executor to invoke the Callable.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
callWithTimeout(java.util.concurrent.Callable<T> callable,
long duration,
java.util.concurrent.TimeUnit unit)
Invokes a specified Callable, timing out after the specified time limit.
|
public TimeLimiter(java.util.concurrent.ExecutorService executor)
executor - ExecutorService used to invoke the callablepublic <T> T callWithTimeout(java.util.concurrent.Callable<T> callable,
long duration,
java.util.concurrent.TimeUnit unit)
throws java.lang.Exception
java.lang.Exception