标签:day01 pack imp please int end img send after
1.介绍
2.简单示例
3.第二个程序
4.通信程序
1 package day01 2 import scala.actors.Actor 3 case class Message(content: String, sender: Actor) 4 class LeoActor extends Actor{ 5 def act(){ 6 while (true){ 7 receive{ 8 case Message(content,sender)=>{ 9 println("leo: " + content) 10 sender ! "please call me after 10 minutes." 11 } 12 } 13 } 14 } 15 } 16 class JackActor(val LeoActor: Actor) extends Actor{ 17 def act(){ 18 LeoActor ! Message("Hello , leo, I‘m Jack. Are you free Now?",this) 19 while (true){ 20 receive{ 21 case re:String => println("Jack: " + re) 22 } 23 } 24 } 25 } 26 27 object ActoyDemo { 28 def main(args: Array[String]) { 29 var Leo=new LeoActor 30 var Jack=new JackActor(Leo) 31 Leo.start() 32 Jack.start() 33 } 34 }
标签:day01 pack imp please int end img send after
原文地址:http://www.cnblogs.com/juncaoit/p/6257617.html