From the well-written Akka Concurrency:
As I understand, the diagram points out, both numSummer
and charConcat
will run on the same thread.
Is it possible to run each Future
in parallel, i.e. on separate threads?
From the well-written Akka Concurrency:
As I understand, the diagram points out, both numSummer
and charConcat
will run on the same thread.
Is it possible to run each Future
in parallel, i.e. on separate threads?
The picture on the left is them running in parallel.
The point of the illustration is that the
Future.apply
method is what kicks off the execution, so if it doesn't happen until the first future's result isflatMap
ed (as in the picture on the right), then you don't get the parallel execution.(Note that by "kicked off", i mean the relevant
ExecutionContext
is told about the job. How it parallelizes is a different question and may depend on things like the size of its thread pool.)Equivalent code for the left:
and for the right: