public final class MoreExecutors extends Object
Modifier and Type | Method and Description |
---|---|
static Executor |
directExecutor()
Returns an
Executor that runs each task in the thread that invokes
execute , as in ThreadPoolExecutor.CallerRunsPolicy . |
public static Executor directExecutor()
Executor
that runs each task in the thread that invokes
execute
, as in ThreadPoolExecutor.CallerRunsPolicy
.
This instance is equivalent to:
final class DirectExecutor implements Executor {
public void execute(Runnable r) {
r.run();
}
}
This should be preferred to #newDirectExecutorService()
because the implementing the
ExecutorService
subinterface necessitates significant performance overhead.
Copyright © 2007-2024,Oracleand/or its affiliates.All Rights Reserved. Use is subject to license terms.