Package com.peterphi.std.threading
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionasyncRun()
Start a new daemon thread to call the run() method asynchronously, returning this object as a Future (and not a RunnableCallableFuture)static <T> Future<T>
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.Runs this Callable asynchronously using the specifiedExecutor
void
run()
toString()
Methods inherited from class com.peterphi.std.threading.SettableFuture
cancel, cancel, fail, get, get, get, isCancelled, isDone, on_cancel, on_set, poll, set
-
Constructor Details
-
RunnableCallableFuture
-
-
Method Details
-
run
public void run()- Specified by:
run
in interfaceRunnable
- Specified by:
run
in interfaceRunnableFuture<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
Runs this Callable asynchronously using the specifiedExecutor
- Parameters:
executor
-- Returns:
-
toString
-
asyncRun
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:
-