X
- Type of inputY
- Type of outputpublic final class Async<X,Y> extends Object implements Func<X,Future<Y>>, Proc<X>
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.
Constructor and Description |
---|
Async(Func<X,Y> fnc)
Ctor.
|
Async(Func<X,Y> fnc,
ExecutorService exec)
Ctor.
|
Async(Func<X,Y> fnc,
ThreadFactory fct)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
Future<Y> |
apply(X input)
Apply it.
|
void |
exec(X input)
Execute it.
|
public Async(Func<X,Y> fnc, ThreadFactory fct)
fnc
- The funcfct
- Factorypublic Async(Func<X,Y> fnc, ExecutorService exec)
fnc
- The funcexec
- Executor ServiceCopyright © 2017–2020 Cactoos. All rights reserved.