How to kill RemoteActor?

Not sure if I missed something. When you remove an actor, the main method does not end.

Here is a snippet demonstrating 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
  }
}
+4
source share
1 answer

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

+4
source

All Articles