CompletableFuture Can't Be Interrupted - DZone Java
I wrote a lot about InterruptedException and interrupting threads already. In short if you call Future.cancel()
not inly given Future
will terminate pending get()
, but also it will try to interrupt underlying thread. This is a pretty important feature that enables better thread pool utilization. I also wrote to always prefer CompletableFuture
over standardFuture
. It turns out the more powerful younger brother of Future
doesn't handle cancel()
so elegantly. Consider the following task, which we'll use later throughout the tests:
Read full article from CompletableFuture Can't Be Interrupted - DZone Java
No comments:
Post a Comment