Package org.cactoos.func
Class Async<X,Y>
- java.lang.Object
-
- org.cactoos.func.Async<X,Y>
-
- Type Parameters:
X
- Type of inputY
- Type of output
public final class Async<X,Y> extends Object implements Func<X,Future<Y>>, Proc<X>
Func that runs in the background.If you want your piece of code to be executed in the background, use
Async
as following:int length = new AsyncFunc( input -> input.length() ).apply("Hello, world!").get();
There is no thread-safety guarantee.
- Since:
- 0.10
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Future<Y>
apply(X input)
Apply it.void
exec(X input)
Execute it.
-
-
-
Constructor Detail
-
Async
public Async(Func<X,Y> fnc, ThreadFactory fct)
Ctor.- Parameters:
fnc
- The funcfct
- Factory
-
Async
public Async(Func<X,Y> fnc, ExecutorService exec)
Ctor.- Parameters:
fnc
- The funcexec
- Executor Service
-
-