提交 ab99ec9a 编写于 作者: 江南烟雨楼台's avatar 江南烟雨楼台

生产代码片段

上级 00470cde
class Main { CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
public static void main(String[] args) { // 异步任务的逻辑
System.out.println("Hello world!"); return "Hello, CompletableFuture!";
} });
}
\ No newline at end of file // 获取异步任务的结果
String result = future.get();
System.out.println(result); // 输出:Hello, CompletableFuture!
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册