How to create a completed future in java

前端 未结 6 886
不思量自难忘°
不思量自难忘° 2021-02-06 20:12

What is the best way to construct a completed future in Java? I have implemented my own CompletedFuture below, but was hoping something like this that already exist

6条回答
  •  孤街浪徒
    2021-02-06 20:34

    In Java 6 you can use the following:

    Promise p = new Promise();
    p.resolve(value);
    return p.getFuture();
    

提交回复
热议问题