标签:
scala自从2.10开始,则直接采用akka作为并发模型,本文作为akka的第一个入门实例。
package com.tv189.actor import akka.actor.{Actor, ActorSystem, Props} /** * Created by molyeo on 2015/8/6. */ object AkkaTest01 extends App { val system = ActorSystem("AkkaTest") val helloActor = system.actorOf(Props[HelloActor], name = "helloActor") helloActor ! "hello" helloActor ! "yes" class HelloActor extends Actor { def receive = { case "hello" => println("hello back to you") case _ => println("huh?") } } }
运行结果如下:
hello back to you
huh?
参考文献:
http://alvinalexander.com/scala/simple-scala-akka-actor-examples-hello-world-actors
标签:
原文地址:http://www.cnblogs.com/molyeo/p/4710285.html