Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AKKA Futures and Java Threads

Tags:

scala

akka

future

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?

like image 975
Anand Avatar asked Feb 09 '23 01:02

Anand


1 Answers

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.

like image 151
Till Rohrmann Avatar answered Feb 15 '23 05:02

Till Rohrmann