Class RunnableCallableFuture<T>

java.lang.Object
com.peterphi.std.threading.SettableFuture<T>
com.peterphi.std.threading.RunnableCallableFuture<T>
Type Parameters:
T -
All Implemented Interfaces:
Runnable, Future<T>, RunnableFuture<T>

public class RunnableCallableFuture<T> extends SettableFuture<T> implements Runnable, RunnableFuture<T>
A wrapper type which takes a Callable and turns it into a RunnableFuture
  • Constructor Details

    • RunnableCallableFuture

      public RunnableCallableFuture(Callable<T> callable)
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
      Specified by:
      run in interface RunnableFuture<T>
    • asyncRun

      public Future<T> asyncRun()
      Start a new daemon thread to call the run() method asynchronously, returning this object as a Future (and not a RunnableCallableFuture)
      Returns:
    • asyncRun

      public Future<T> asyncRun(Executor executor)
      Runs this Callable asynchronously using the specified Executor
      Parameters:
      executor -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • asyncRun

      public static <T> Future<T> asyncRun(Callable<T> callable)
      Takes a Callable, executing it in the background, returning a Future to its result
      Users are advised to use a ThreadPool instead of this method.
      Type Parameters:
      T - the return type
      Parameters:
      callable - the callable to return a Future to
      Returns: