How do I kill a RemoteActor?

淺唱寂寞╮ 提交于 2019-12-19 08:18:26

问题


Not sure whether I am missing something. When making an actor remote, the main method does not terminate.

Here is a snippet that demonstrates the problem.

import scala.actors._
import scala.actors.remote._
object TestMe {
  def main(args : Array[String]) : Unit = {
      object jim extends DaemonActor {
          // comment out these two lines and the application will terminate
          RemoteActor.alive(12345)
          RemoteActor.register('jim,this)         
          def act {
              loop {
                  receive {
                      case 'quit =>
                       println("\nquiting")
                        exit('normal)
                      case any => 
                        println(any)
                  }
              }
          }
      }
      jim.start
      jim ! "hello"
      jim ! 'quit
  }
}

回答1:


Put your .alive and .register calls inside act() and your code successfully terminates.



来源:https://stackoverflow.com/questions/3330096/how-do-i-kill-a-remoteactor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!