cost 75 ms
在 CompletableFuture 中返回 autocloseable object 并在 whenComplete 中使用它 - Return autocloseable object inside a CompletableFuture and use it in whenComplete

我想在 CompletableFuture 中返回一个可自动关闭的 object 并在 whenComplete 中使用它,而无需稍后手动关闭它。 这是我试过的代码,但当然它不会工作,因为当我返回 Jedis object 时它会自动关闭。我没有任何其他想法。 ...

具有 AutoCloseable 类型和返回布尔值的 lambda 的 Kotlin `use` - Kotlin `use` with AutoCloseable type and a lambda returning Boolean

这一定很简单,但我已经用头撞了半个小时了......这是我的旧的,异常不安全的代码: 我想重写它以使用use ,如下所示: 但是 Kotlin 给了我一个错误: 或者,我说“好吧,我不懂简洁的 lambda 语法,让我用fun ”,然后我试试这个: Kotlin 仍然抱怨: 我 ...


排序:
质量:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM