public class MultithreadExecutors extends Object
Thread#stop() will occur "java.lang.ThreadDeath: null" if try...catch wrapped in Throwable
| 构造器和说明 |
|---|
MultithreadExecutors() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> void |
execute(Collection<T> coll,
Consumer<T> action,
Executor executor)
Run async, action the T collection
|
static <T> void |
execute(Collection<T> data,
Consumer<T> action,
int dataSizeThreshold,
Executor executor)
根据数据(任务)数量来判断是否主线程执行还是提交到线程池执行
|
static <T,R> List<R> |
execute(Collection<T> data,
Function<T,R> action,
int dataSizeThreshold,
Executor executor)
根据数据(任务)数量来判断是否主线程执行还是提交到线程池执行
|
static <T,U> List<U> |
execute(Collection<T> coll,
Function<T,U> mapper,
Executor executor)
Call async, mapped T to U
|
static void |
execute(int parallelism,
Runnable command,
int execSeconds,
Executor executor)
Exec async, usual use in test case
|
static void |
execute(Runnable command,
int parallelism,
Executor executor)
Exec async
|
static <U> List<U> |
execute(Supplier<U> supplier,
int parallelism) |
static <T> List<T> |
join(CompletionService<T> service,
int count) |
static <T> void |
join(CompletionService<T> service,
int count,
Consumer<T> accept) |
static <T> void |
joinDiscard(CompletionService<T> service,
int count) |
public static void execute(int parallelism,
Runnable command,
int execSeconds,
Executor executor)
parallelism - the parallelismcommand - the commandexecSeconds - the execSecondsexecutor - the executorpublic static void execute(Runnable command, int parallelism, Executor executor)
command - the commandparallelism - the parallelismexecutor - thread executor servicepublic static <T> void execute(Collection<T> coll, Consumer<T> action, Executor executor)
coll - the T collectionaction - the T actionexecutor - thread executor servicepublic static <T,U> List<U> execute(Collection<T> coll, Function<T,U> mapper, Executor executor)
coll - the T collectionmapper - the mapper of T to Uexecutor - thread executor servicepublic static <T,R> List<R> execute(Collection<T> data, Function<T,R> action, int dataSizeThreshold, Executor executor)
T - data element typeR - result element typedata - the dataaction - the actiondataSizeThreshold - the dataSizeThresholdexecutor - the executorpublic static <T> void execute(Collection<T> data, Consumer<T> action, int dataSizeThreshold, Executor executor)
T - data element typedata - the dataaction - the actiondataSizeThreshold - the dataSizeThresholdexecutor - the executorpublic static <T> List<T> join(CompletionService<T> service, int count)
public static <T> void joinDiscard(CompletionService<T> service, int count)
public static <T> void join(CompletionService<T> service, int count, Consumer<T> accept)
Copyright © 2023. All rights reserved.