0

Recently I implement a remote actor mode in my project. I would like to know which way is concurrently running the Actors.

Way 1.

for(int i = 0; i < 100; i++){
   Patterns.ask(Props.create(Worker.class),$someJobs, timeout);
}

Way 2.

for(int i = 0; i < 100; i++){
new Thread(new Runnable() {

        @Override
        public void run() {
            // 
            getContext().actorOf(Props.create(Worker.class)).tell($someJobs,   getSelf());
        }
    }).start();
  }

In the way1, I print out the thread name like -akka.actor.default-dispatcher-4, but the dispatcher never come to 100. Why?

Thanks a lot

user1438980
  • 187
  • 1
  • 3
  • 13
  • Please post your worker code. You shouldn't be using threads, as the ask method returns a Future object. – ra2085 Jul 29 '14 at 02:56
  • 1
    What are you trying to achieve? In both situations messages are being send and handled concurrently. You are seeing 4 dispatchers probably because you are running your code on a 2 core machine with a parallelism factor of 2. More information about dispatcher configuration can be found in the [docs](http://doc.akka.io/docs/akka/2.3.4/scala/dispatchers.html). – dvim Jul 29 '14 at 11:00
  • I find the problem that I need to modify the value of parallelism-max , then I can see the more dispatcher – user1438980 Jul 31 '14 at 02:30

0 Answers0