俳優を始めてから
val a = actor {
loop {
react {
case "end" => exit
...
}
}
}
そして、それに「終了」メッセージを送信します
a ! "end"
スレッドが終了したことを確認したい。どのように参加できますか?
俳優を始めてから
val a = actor {
loop {
react {
case "end" => exit
...
}
}
}
そして、それに「終了」メッセージを送信します
a ! "end"
スレッドが終了したことを確認したい。どのように参加できますか?
私には、あなたが望むことを行う「アクターウェイ」は、実際にはアクターにリクエスターに「完了」というメッセージを返信させることであるように思われます。これにより、アクションを実行できます。そうすれば、それはすべてまだ非同期のイベント処理です
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.