On Wednesday, April 15, 2015 at 10:37:36 PM UTC+5:30, Michael Frank wrote: > > 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. > > >> How does akka make sure that while processing a certain message, no other message thread will be processed or there will be no context switch ? Or it just uses low level constructs of locking on a certain message before processing it, even though context switch for that message thread happens, it wont release the lock till message is processed (This can cause trouble in blocking I/O). > > 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 > -- >>>>>>>>>> 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 --- You received this message because you are subscribed to the Google Groups "Akka User List" group. 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.
