Actors are thread safe inside them "by definition". The actor has one mailbox and processes the messages one by one from it. We guarantee that fields are properly visible, even if the actor jumps around threads - no need for CHM in the actor
On Thu, May 15, 2014 at 7:31 AM, Leon Ma <tutuf...@gmail.com> wrote: > Hi, > > Assuming I have an actor which hold a map M > > And I will possibly do: > > 1, send message A to the actor > 2. send message B to the actor > > > When receiving messages, A will possibly be executed in thread 1 and B > will possibly be executed in thread 2. > Although A is triggered earlier than B ( sequence delivery is for sure), > but B might be finished executing prior to A, right? > > > Assuming in the receive method, I'll try to do something like "find an > entry from the map M, if not exist, then create one". > > Will I see any possible concurrent issues? should I use a thread safe map > impl like TrieMap or ConcurrentHashMap to make sure the put operation is > atomic like putIfAbsent? > > > > Thanks > > Leon > > > > > -- > >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Cheers, Konrad 'ktoso' Malawski hAkker - Typesafe, Inc <http://www.scaladays.org/> -- >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.