Note that Props(new MyActor) variant is only dangerous when you're calling it within another actor (due to closing over the enclosing actor's this). To overcome the danger, define a props factory in MyActor's companion object, and specify a default parameter value for it instead of in the actor's constructor:

object MyActor {
  def props(arg: Int = 5): Props = Props(new MyActor(arg))
class MyActor(arg: Int) extends Actor {

And then


Related Query

More Query from same tag