O'Reilly logo

Programming Concurrency on the JVM by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending and Receiving Messages

We can send just about any type of message to an actor—String, Integer, Long, Double, List, Map, tuples, Scala case classes…all of which are immutable. I have a special liking for tuples, not because it’s amusing when we mispronounce them as “two-ples” but because they’re lightweight, immutable, and one of the easiest instances to create. For example, to create a tuple of two numbers in Scala, we simply write (number1, number2). Scala’s case classes are ideal to serve as message types—they’re immutable, work well with pattern matching, and are quite easy to make copy of. In Java we could pass an unmodifiable Collection as messages to send more than one object in a message. When we pass a message to an actor, by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required