How to create a completed future in java

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

    Apache Commons Lang defines similar implementation that is called ConstantFuture, you can get it by calling:

    Future future = ConcurrentUtils.constantFuture(T myValue);
    

提交回复
热议问题