On 04/15/15 04:47, Rohit Jain wrote:
How does using akka actor helps in achieving concurrency without use of any external locks? Is it because at a moment only one message can be processed for one actor ? Hence no 2 threads can be acting upon same actor ?
that is correct. processing within the receive loop of an actor is single threaded.
If that is the case, then maximum number of threads we require is equal to number of actors in our system.
if all your actors perform blocking work in their receive loop, then that would be true. however, you should design your application to be non-blocking (http://www.reactivemanifesto.org/glossary#Non-Blocking). if you need to perform blocking work, then you should use Futures (http://doc.akka.io/docs/akka/2.3.9/scala/futures.html) to schedule the work on a separate, dedicated dispatcher (http://doc.akka.io/docs/akka/2.3.9/scala/dispatchers.html). You can then pipe the result of the Future to an actor (http://doc.akka.io/docs/akka/2.3.9/scala/futures.html#Use_With_Actors) for further processing if necessary.
-Michael --
--- You received this message because you are subscribed to the Google Groups "Akka User List" group.Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
