multithreading - synchronisation on a block of code using akka -
i want use akka in application multi processing. so, same block of code gets executed each actor , results aggregated listener. so, question there synchronisation problem in case. if not how being handled akka actors internally.
by default there should not synchronization problems - if strictly respect actor approach. means actors should communicate using messages contain immutable objects - , should never expose internal state of actor outer world directly. make internal state mutable/readable solely reacting received messages.
each actor executed in own executioncontext. means each actor has own private state. akka actors designed in way accessing internal state "outer world" not possible (or made hard) since after creating new actor, have intermediary reference actor (an actorref instance), not reference actual actor instance in memory. intention of akka developers way: made hard developers the actual reference , access properties directly - break actor approach.
if - on other hand - pass shared mutable object actor, have hassle locks , synchronization have instance using threads.
Comments
Post a Comment