After starting an actor
val a = actor {
loop {
react {
case "end" => exit
...
}
}
}
And sending “end” message to it
a ! "end"
I want to make sure the thread is finished.
How can it be joined?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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/999865If 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.