This is the code that works. He sends a message to the actor (Greeter) and waits for a response. But it blocks the current thread.
public class Future1Blocking { public static void main(String[] args) throws Exception { ActorSystem system = ActorSystem.create("system"); final ActorRef actorRef = system.actorOf(Props.create(Greeter.class), "greeter"); Timeout timeout = new Timeout(Duration.create(5, "seconds")); Future<Object> future = Patterns.ask(actorRef, Greeter.Msg.GREET, timeout);
What is the possible way to use my future.onSuccess example to get the result without blocking the current calling thread?
source share