import scala.actors.Actor import scala.actors.Actor._ case class PersonMessage(name:String,age:Int) class MessageActor extends Actor{ def act{ while(true){ //接收郵件 receive{ case PersonMessage(name,age)=>{ println("person name:"+name+";Person age:"+age) //向發送者發送郵件 sender!"finish!" } } } } } object TestMain{ def main(args: Array[String]): Unit = { val HActor = new MessageActor HActor.start() HActor!PersonMessage("a",12) self.receive{ case msg=>println(msg) } } }