$ more Main.scala
import scala.actors.Actor._
import scala.actors._
package com.ykishi.scala {
object Main extends Actor {
case class MetaInfo ( key: Int, value: String )
def act() {
react {
case s: String =>
reply ( "Thanks! " + s )
act()
case m: MetaInfo =>
println ( "*** received: " + m.key + "," + m.value )
reply ( "successfully completed!" )
act()
case -1 => {
reply ( "BYE!" )
exit()
}
}
}
def main ( args: Array[String] ) {
var a = Main.start()
println ( a !? "HELLO!" )
println ( a !? MetaInfo ( 1123, "KISHI Yasuhiro" ) )
val retval = a !? -1
println ( "Actor's reply: " + retval )
}
}
}
$ ./test1.sh
Thanks! HELLO!
*** received: 1123,KISHI Yasuhiro
successfully completed!
Actor's reply: BYE!
Tidak ada komentar:
Posting Komentar