0

俳優を始めてから

val a = actor {
  loop {
    react {
      case "end" => exit
      ...
    }
  }
}

そして、それに「終了」メッセージを送信します

a ! "end"

スレッドが終了したことを確認したい。どのように参加できますか?

4

2 に答える 2

2

私には、あなたが望むことを行う「アクターウェイ」は、実際にはアクターにリクエスターに「完了」というメッセージを返信させることであるように思われます。これにより、アクションを実行できます。そうすれば、それはすべてまだ非同期のイベント処理です

于 2012-11-08T10:16:07.987 に答える
2

As far as I know an actor can't be joined explicitly as in the Java-way. The concept is to introduce event-based programming, so it should only react on events. You can trap the exit however and link your initial actor (A) to the ending actor (B) via link. That way the initial actor A receives an event when B ends. If you don't get any event you know the actor hasn't terminated. See the thread here: https://stackoverflow.com/a/4304602/999865

If you don't care about resources and knows that the thread will terminate you can also make the actor inherit from DaemonActor. Daemon actors doesn't block any system resources.

于 2012-11-08T09:10:00.580 に答える