Akka actors and shared data: thead-safe, thread-unsafe, or ThreadLocal?

480 views Asked by At

Say I have several UntypedActor classes that each get FizzBuzz references:

class FooActor extends UntypedActor {
    FizzBuzz fizzBuzz

    @Override
    void onReceive(Object message) {
        // whatever...
    }
}

class BarActor extends UntypedActor {
    FizzBuzz fizzBuzz

    @Override
    void onReceive(Object message) {
        // whatever...
    }
}

If both are injected with the same instance of FizzBuzz, then:

Can each actor both read and write to fizzBuzz in a thread-safe manner? Meaning, can FooActor write a change to fizzBuzz that will then be immediately seen over in BarActor? Or does Akka provide each actor instance its own ThreadLocal copy?

Also, same question as above, but for multiple instances of the same actor class (e.g. if there are 10 FooActors, etc.).

0

There are 0 answers