I have a question on the usage of Futures in one of the questions asked - Are Futures executed on a single thread? (Scala) . If for reach Future a new/independent thread is used, then what advantage does AKKA offer than Java threads? The number of WebClients are limited by the max number of thread that the application can spawn right? And the number of threads will be very less compared to number of actors that the system can create. I just wanted to know if there are any other approaches so that when huge number of requests come in, the system will be able to handle them?
Futures
are executed using an ExecutionContext
. There are multiple ways to construct an ExecutionContext
. One of them is to create it using an ExecutionService
. The ExecutionService
can be a ForkJoinPool
or a ThreadPoolExecutor
, for example. Depending on the implementation of the ExecutionService
, your futures will be executed spawning a new Thread
or reusing existing ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With