All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamroute.common.util.AsyncUtil Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
package com.github.dreamroute.common.util;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Supplier;

/**
 * 描述:异步处理工具类
 *
 * @author w.dehai
 */
public class AsyncUtil {

    private AsyncUtil() {}

    public  static  CompletableFuture supply(Supplier supplier) {
        return CompletableFuture.supplyAsync(supplier);
    }

    public  static  CompletableFuture supply(Supplier supplier, Executor executor) {
        return CompletableFuture.supplyAsync(supplier, executor);
    }

    public static CompletableFuture run(Runnable runnable) {
        return CompletableFuture.runAsync(runnable);
    }

    public static CompletableFuture run(Runnable runnable, Executor executor) {
        return CompletableFuture.runAsync(runnable, executor);
    }

    public static CompletableFuture allOf(CompletableFuture... cs) {
        return CompletableFuture.allOf(cs);
    }

    public static CompletableFuture anyOf(CompletableFuture... cs) {
        return CompletableFuture.anyOf(cs);
    }
}