Package dev.failsafe

Class TimeoutBuilder<R>

Type Parameters:
R - result type
All Implemented Interfaces:
PolicyListeners<TimeoutBuilder<R>,R>

public class TimeoutBuilder<R> extends PolicyBuilder<TimeoutBuilder<R>,TimeoutConfig<R>,R>
Builds Timeout instances.

This class is not threadsafe.

See Also:
  • Constructor Details

  • Method Details

    • build

      public Timeout<R> build()
      Builds a new Timeout using the builder's configuration.
    • withInterrupt

      public TimeoutBuilder<R> withInterrupt()
      Configures the policy to interrupt an execution in addition to cancelling it when the timeout is exceeded. For synchronous executions this is done by calling Thread.interrupt() on the execution's thread. For asynchronous executions this is done by calling Future.cancel(true). Executions can internally cooperate with interruption by checking Thread.isInterrupted() or by handling InterruptedException where available.

      Note: Only configure interrupts if the code being executed is designed to be interrupted.

      Note: interruption will have no effect when performing an async execution since the async thread is unknown to Failsafe.