```java import java.util.concurrent.CompletableFuture; public class AsyncDemo { public static void main(String[] args) { asyncMethod().thenAccept(result -> System.out.println("异步方法执行结果: " + result)); System.out.println("主线程继续执行"); } public static CompletableFuture<String> asyncMethod() { return CompletableFuture.supplyAsync(() -> { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } return "Hello, World!"; }); } } ``` [2024-05-24 16:21:52 | AI写代码神器 | 165点数解答]