| Modifier and Type | Method and Description |
|---|---|
| public <T extends @Nullable Object> T | Returns: the result returned by the Callablethe Callable to execute callable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Invokes a specified Callable, timing out after the specified time limit. |
| public default <T extends @Nullable Object> T | Returns: the result returned by the Callablethe Callable to execute callable, Duration the maximum length of time to wait timeout)Invokes a specified Callable, timing out after the specified time limit. |
| public <T extends @Nullable Object> T | Returns: the result returned by the Callablethe Callable to execute callable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Invokes a specified Callable, timing out after the specified time limit. |
| public default <T extends @Nullable Object> T | Returns: the result returned by the Callablethe Callable to execute callable, Duration the maximum length of time to wait timeout)Invokes a specified Callable, timing out after the specified time limit. |
| public <T> T | Returns: a time-limiting proxythe object to proxy target, Class<T> the interface you wish the returned proxy to implement interfaceType, long with timeoutUnit, the maximum length of time that callers are willing to
wait on each method call to the proxy timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time that callers are willing to
wait on each method call to the proxy timeoutUnit)Returns an instance of |
| public default <T> T | Returns: a time-limiting proxythe object to proxy target, Class<T> the interface you wish the returned proxy to implement interfaceType, Duration the maximum length of time that callers are willing to wait on each method call
to the proxy timeout)Returns an instance of |
| public void | runUninterruptiblyWithTimeout(Runnable
the Runnable to execute runnable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Invokes a specified Runnable, timing out after the specified time limit. |
| public default void | runUninterruptiblyWithTimeout(Runnable
the Runnable to execute runnable, Duration the maximum length of time to wait timeout)Invokes a specified Runnable, timing out after the specified time limit. |
| public void | runWithTimeout(Runnable
the Runnable to execute runnable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Invokes a specified Runnable, timing out after the specified time limit. |
| public default void | runWithTimeout(Runnable
the Runnable to execute runnable, Duration the maximum length of time to wait timeout)Invokes a specified Runnable, timing out after the specified time limit. |
| callUninterruptiblyWithTimeout | back to summary |
|---|---|
| public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, ExecutionException Invokes a specified Callable, timing out after the specified time limit. If the target method
call finishes before the limit is reached, the return value or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the call to
the target, and throw a The difference with
| |
| callUninterruptiblyWithTimeout | back to summary |
|---|---|
| public default <T extends @Nullable Object> T callUninterruptiblyWithTimeout(Callable<T> callable, Duration timeout) throws TimeoutException, ExecutionException Invokes a specified Callable, timing out after the specified time limit. If the target method
call finishes before the limit is reached, the return value or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the call to
the target, and throw a The difference with
| |
| callWithTimeout | back to summary |
|---|---|
| public <T extends @Nullable Object> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException, ExecutionException Invokes a specified Callable, timing out after the specified time limit. If the target method
call finishes before the limit is reached, the return value or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the call to
the target, and throw a
| |
| callWithTimeout | back to summary |
|---|---|
| public default <T extends @Nullable Object> T callWithTimeout(Callable<T> callable, Duration timeout) throws TimeoutException, InterruptedException, ExecutionException Invokes a specified Callable, timing out after the specified time limit. If the target method
call finishes before the limit is reached, the return value or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the call to
the target, and throw a
| |
| newProxy | back to summary |
|---|---|
| public <T> T newProxy(T target, Class<T> interfaceType, long timeoutDuration, TimeUnit timeoutUnit) Returns an instance of If the target method call finishes before the limit is reached, the return value or
exception is propagated to the caller exactly as-is. If, on the other hand, the time limit is
reached, the proxy will attempt to abort the call to the target, and will throw an It is important to note that the primary purpose of the proxy object is to return control to the caller when the timeout elapses; aborting the target method call is of secondary concern. The particular nature and strength of the guarantees made by the proxy is implementation-dependent. However, it is important that each of the methods on the target object behaves appropriately when its thread is interrupted. For example, to return the value of
TimeLimiter limiter = . . .;
TargetType proxy = limiter.newProxy(
target, TargetType.class, 50, TimeUnit.MILLISECONDS);
try {
return proxy.someMethod();
} catch (UncheckedTimeoutException e) {
return DEFAULT_VALUE;
}
| |
| newProxy | back to summary |
|---|---|
| public default <T> T newProxy(T target, Class<T> interfaceType, Duration timeout) Returns an instance of If the target method call finishes before the limit is reached, the return value or
exception is propagated to the caller exactly as-is. If, on the other hand, the time limit is
reached, the proxy will attempt to abort the call to the target, and will throw an It is important to note that the primary purpose of the proxy object is to return control to the caller when the timeout elapses; aborting the target method call is of secondary concern. The particular nature and strength of the guarantees made by the proxy is implementation-dependent. However, it is important that each of the methods on the target object behaves appropriately when its thread is interrupted. For example, to return the value of
TimeLimiter limiter = . . .;
TargetType proxy = limiter.newProxy(target, TargetType.class, Duration.ofMillis(50));
try {
return proxy.someMethod();
} catch (UncheckedTimeoutException e) {
return DEFAULT_VALUE;
}
| |
| runUninterruptiblyWithTimeout | back to summary |
|---|---|
| public void runUninterruptiblyWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException Invokes a specified Runnable, timing out after the specified time limit. If the target method
run finishes before the limit is reached, this method returns or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the run, and
throw a The difference with
| |
| runUninterruptiblyWithTimeout | back to summary |
|---|---|
| public default void runUninterruptiblyWithTimeout(Runnable runnable, Duration timeout) throws TimeoutException Invokes a specified Runnable, timing out after the specified time limit. If the target method
run finishes before the limit is reached, this method returns or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the run, and
throw a The difference with
| |
| runWithTimeout | back to summary |
|---|---|
| public void runWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException Invokes a specified Runnable, timing out after the specified time limit. If the target method
run finishes before the limit is reached, this method returns or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the run, and
throw a
| |
| runWithTimeout | back to summary |
|---|---|
| public default void runWithTimeout(Runnable runnable, Duration timeout) throws TimeoutException, InterruptedException Invokes a specified Runnable, timing out after the specified time limit. If the target method
run finishes before the limit is reached, this method returns or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the run, and
throw a
| |