diff --git a/src/main/java/org/cactoos/func/AsyncFunc.java b/src/main/java/org/cactoos/func/AsyncFunc.java index 21c08b5749..5c5a5cbe77 100644 --- a/src/main/java/org/cactoos/func/AsyncFunc.java +++ b/src/main/java/org/cactoos/func/AsyncFunc.java @@ -25,6 +25,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.ThreadFactory; import org.cactoos.Func; /** @@ -52,17 +53,32 @@ public final class AsyncFunc implements Func> { */ private final Func func; + /** + * The threads. + */ + private final ThreadFactory factory; + /** * Ctor. * @param fnc The proc */ public AsyncFunc(final Func fnc) { + this(fnc, Executors.defaultThreadFactory()); + } + + /** + * Ctor. + * @param fnc The proc + * @param fct Factory + */ + public AsyncFunc(final Func fnc, final ThreadFactory fct) { this.func = fnc; + this.factory = fct; } @Override public Future apply(final X input) throws Exception { - return Executors.newSingleThreadExecutor().submit( + return Executors.newSingleThreadExecutor(this.factory).submit( () -> this.func.apply(input) ); }