// 异步操作
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,
1,
0L,
TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<>(2),
new ThreadPoolExecutor.AbortPolicy());
CompletableFuture.runAsync(() -> {
try {
// 这里填写需要异步处理的代码方法
} catch (Exception e) {
e.printStackTrace();
}
}, threadPoolExecutor);
threadPoolExecutor.shutdown();
Java异步代码
最新推荐文章于 2024-07-05 17:25:50 发布