170 Scala Actor 案例四
结合case class发送消息,代码如下:package cn.itcast.actor package cn.itcast.actor import scala.actors.Actor class AppleActor extends Actor { def act(): Unit = { while (true) { receive { case ...
170 Scala Actor 案例三
react方式会复用线程,比receive更高效,代码如下:package cn.itcast.actor import scala.actors.Actor class YourActor extends Actor { override def act(): Unit = { loop { react { case "start" => { ...
169 Scala Actor 案例二
使用Actor可以不断地接收消息,先看如下代码:package cn.itcast.actor import scala.actors.Actor class MyActor extends Actor { override def act(): Unit = { while (true) { receive { case "start" => { ...
168 Scala Actor 案例一
先看代码:package cn.itcast.actor //注意导包是scala.actors.Actor import scala.actors.Actor object MyActor1 extends Actor{ //重新act方法 def act(){ for(i <- 1 to 10){ println("actor-1 " + i) ...
本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。
开发与运维
集结各类场景实战经验,助你开发运维畅行无忧
+关注