I have a method on some repository class that returns a CompletableFuture
. The code that completes these futures uses a third party library which blocks. I intend t
Just from my empirical observations while playing around with it, the thread that executes these non-async methods will depend on which happens first, thenCompose
itself or the task behind the Future
.
If thenCompose
completes first (which, in your case, is almost certain), then the method will run on the same thread that is executing the Future
task.
If the task behind your Future
completes first, then the method will run immediately on the calling thread (i.e. no executor at all).