public class RunUtil extends Object
| Constructor and Description |
|---|
RunUtil() |
| Modifier and Type | Method and Description |
|---|---|
static CompletableFuture<Void> |
async(Runnable task)
异步执行
|
static <U> CompletableFuture<U> |
async(Supplier<U> task)
异步执行
|
static CompletableFuture<Void> |
asyncAndTry(RunnableEx task)
异步执行并吃掉异常
|
static <T> T |
callAndTry(Callable<T> task)
调用并吃掉异常
|
static ScheduledFuture<?> |
delay(Runnable task,
long millis)
延迟执行
|
static ScheduledFuture<?> |
delayAndRepeat(Runnable task,
long millis)
延迟执行并重复
|
static <T> Future<T> |
parallel(Callable<T> task)
Deprecated.
3.0
async(Runnable) |
static Future<?> |
parallel(Runnable task)
Deprecated.
3.0
async(Runnable) |
static void |
preheat()
预热(初始化线程池)
|
static void |
runAndTry(RunnableEx task)
运行并吃掉异常
|
static void |
runOrThrow(RunnableEx task)
运行或异常
|
static ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
long initialDelay,
long millisPeriod)
定时任务
|
static ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
long initialDelay,
long millisDelay)
定时任务
|
static void |
setAsyncExecutor(ExecutorService asyncExecutor)
设置异步执行器
|
static void |
setParallelExecutor(ExecutorService parallelExecutor)
Deprecated.
3.0
|
static void |
setScheduledExecutor(ScheduledExecutorService scheduledExecutor)
设置调度执行器
|
static void |
shutdown()
关闭(再次调用时,可自动恢复)
|
public static void shutdown()
public static void preheat()
@Deprecated public static void setParallelExecutor(ExecutorService parallelExecutor)
public static void setScheduledExecutor(ScheduledExecutorService scheduledExecutor)
public static void setAsyncExecutor(ExecutorService asyncExecutor)
public static void runOrThrow(RunnableEx task)
public static void runAndTry(RunnableEx task)
public static <T> T callAndTry(Callable<T> task)
@Deprecated public static Future<?> parallel(Runnable task)
async(Runnable)@Deprecated public static <T> Future<T> parallel(Callable<T> task)
async(Runnable)public static CompletableFuture<Void> async(Runnable task)
public static <U> CompletableFuture<U> async(Supplier<U> task)
public static CompletableFuture<Void> asyncAndTry(RunnableEx task)
public static ScheduledFuture<?> delay(Runnable task, long millis)
public static ScheduledFuture<?> delayAndRepeat(Runnable task, long millis)
public static ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long millisPeriod)
public static ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long millisDelay)
Copyright © 2025. All rights reserved.