Last active
March 27, 2019 16:43
-
-
Save jboner/9990472 to your computer and use it in GitHub Desktop.
Revisions
-
jboner revised this gist
Apr 5, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ object PingPong extends App { case Ball => counter += 1 println(s"Ping counter: ${counter}") Thread.sleep(1000) // you should *never* call Thread.sleep in a real application, just here to slow things down sender ! Ball } } -
jboner created this gist
Apr 5, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ package demo import akka.actor.{Actor, Props, ActorSystem} object PingPong extends App { case object Ball class Ping extends Actor { var counter = 0 def receive = { case Ball => counter += 1 println(s"Ping counter: ${counter}") Thread.sleep(1000) sender ! Ball } } class Pong extends Actor { var counter = 0 def receive = { case Ball => counter += 1 println(s"Pong counter: ${counter}") Thread.sleep(1000) sender ! Ball } } val system = ActorSystem("pingpong") val ping = system.actorOf(Props(classOf[Ping]), "ping") val pong = system.actorOf(Props(classOf[Pong]), "pong") ping.tell(Ball, pong) }