Improve wordings in actor-systems.md Adding Java samples in actor-systems.md, and description for scala.concurrent.blocking() inside Future Move the section for blocking operations to dispatchers.md Fix minor issues in dispatchers.md Remove note about scala.concurrent.blocking which would be unnecessary. Correcting a typo "run run"
46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
/**
|
|
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
|
|
*/
|
|
|
|
package jdocs.actor;
|
|
|
|
import akka.actor.ActorRef;
|
|
import akka.actor.ActorSystem;
|
|
import akka.actor.Props;
|
|
import com.typesafe.config.Config;
|
|
import com.typesafe.config.ConfigFactory;
|
|
|
|
class SeparateDispatcherTest {
|
|
public static void main(String args[]) {
|
|
Config config = ConfigFactory.parseString(
|
|
"my-blocking-dispatcher {\n" +
|
|
" type = Dispatcher\n" +
|
|
" executor = \"thread-pool-executor\"\n" +
|
|
" thread-pool-executor {\n" +
|
|
" fixed-pool-size = 16\n" +
|
|
" }\n" +
|
|
" throughput = 1\n" +
|
|
"}\n"
|
|
);
|
|
|
|
ActorSystem system = ActorSystem.create("BlockingDispatcherTest", config);
|
|
|
|
try {
|
|
// #separate-dispatcher-main
|
|
ActorRef actor1 = system.actorOf(Props.create(SeparateDispatcherFutureActor.class));
|
|
ActorRef actor2 = system.actorOf(Props.create(PrintActor.class));
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
actor1.tell(i, ActorRef.noSender());
|
|
actor2.tell(i, ActorRef.noSender());
|
|
}
|
|
// #separate-dispatcher-main
|
|
Thread.sleep(5000 * 6);
|
|
|
|
} catch (InterruptedException e) {
|
|
//swallow the exception
|
|
} finally {
|
|
system.terminate();
|
|
}
|
|
}
|
|
}
|