Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import scala.actors.Actor
  2.  
  3. class Foo extends Exception
  4.  
  5. class MyActor extends Actor {
  6. def act {
  7. loop {
  8. react {
  9. case x =>
  10. try {
  11. x match {
  12. case "die" => throw new Foo
  13. case _ => println("nothing...")
  14. }
  15. } catch {
  16. case _ => println("got exception")
  17. }
  18. }
  19. }
  20. }
  21. }
  22.  
  23. object App {
  24. def main(args: Array[String]): Unit = {
  25. val a = new MyActor
  26. println("starting actor...")
  27. a.start
  28.  
  29. a ! "hello"
  30. a ! "die"
  31. a ! "hello"
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment