/**
* 异步删除
*
* @param keys
*/
public void asycExecute(String keys) {
ExecutorService executor = Executors.newFixedThreadPool(1);
CompletableFuture<String> future = CompletableFuture.supplyAsync(new Supplier<String>() {
@Override
public String get() {
LOGGER.info("task started!");
try {
// 异步删除
removeAll(keys);
} catch (Exception e) {
LOGGER.info("异步删除出现异常:" + e);
}
return "task finished!";
}
}, executor);
future.thenAccept(e -> System.out.println(e + " 异步删除成功"));
}