How to create a completed future in java

前端 未结 6 859
不思量自难忘°
不思量自难忘° 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:33

    I found a very similar class to yours in the Java rt.jar

    com.sun.xml.internal.ws.util.CompletedFuture

    It allows you to also specify an exception that can be thrown when get() is invoked. Just set that to null if you don't want to throw an exception.

提交回复
热议问题