赞
踩
同样,可以使用thenAcceptAsync
方法, 串联的CompletableFuture可以异步地执行。
- static void thenAcceptAsyncExample() {
- StringBuilder result = new StringBuilder();
- CompletableFuture cf = CompletableFuture.completedFuture("thenAcceptAsync message")
- .thenAcceptAsync(s -> result.append(s));
- cf.join();
- assertTrue("Result was empty", result.length() > 0);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。