爷的眼睛闪亮
insideDotNet En_summerGarden

/**
* 异步删除
*
* @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 + " 异步删除成功"));
}

posted on 2019-06-17 11:12  爷的眼睛闪亮  阅读(559)  评论(0编辑  收藏  举报