小编ach*_*uth的帖子

知道akka演员存在的三种方法

我正在研究akka演员(JAVA),最近才知道有3种方式(可能更多)知道演员的存在.

  1. 发送识别消息:

    ActorSelection sel = actorSystem.actorSelection("akka://test/user/TestActor");
    AskableActorSelection asker = new AskableActorSelection(sel);
    Future<Object> future = asker.ask(new Identify(1), new Timeout(5,
            TimeUnit.SECONDS));
    ActorIdentity identity = (ActorIdentity) Await.result(future, timeOut.duration());
    ActorRef reference = identity.getRef();
    if(reference != null){
      // Actor exists
    } else {
    // Actor does not exits
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. resolveOne方法:

    ActorSelection sel = actorSystem.actorSelection("akka://test/user/TestActor");
    Future<ActorRef> future = sel.resolveOne(new Timeout(5,
            TimeUnit.SECONDS));
    // Wait for the completion of task to be completed.
    future.onComplete(new OnComplete<ActorRef>() {
        @Override
        public void onComplete(Throwable excp, ActorRef child)
                throws Throwable { …
    Run Code Online (Sandbox Code Playgroud)

java akka

10
推荐指数
1
解决办法
5153
查看次数

获取HashMap中的键列表,其中包含"some value"之类的键

在Mysql中我们可以查询具有子句" WHERE name LIKE'%someName%' "的表,我们可以在java中使用与HashMap相同的功能,如果是这样的话,我们如何通过不迭代每个元素在更短的时间内更有效地实现这一功能?

java hashmap

6
推荐指数
2
解决办法
4627
查看次数

标签 统计

java ×2

akka ×1

hashmap ×1