如何创建org.springframework.util.concurrent.ListenableFuture
的虚拟实例?
它应该代表具有给定结果的已完成任务。
最佳答案
假设字符串结果
,您可以使用以下内容:
String result = "result";
ListenableFuture<String> future = new AsyncResult<>(result);
String dummy = future.get();
但是,如果需要,任何对象
都可以包装在AsyncResult
中。
关于java - 如何创建 org.springframework.util.concurrent.ListenableFuture 的完整实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54590721/