O'Reilly logo

Introduction to JVM Languages by Vincent van der Leun

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

The main application

We will create a simple console-based application that adds some quotes to the collection and then prints a random one. It will communicate by sending messages to actors. A message handler inside actors is not supposed to block, meaning it should not run code that takes time to complete in the same thread. Our actors adhere to this rule; both actors process messages directly and return immediately.

To demonstrate the working of both the actors, we will do something different for the main program. When sending a message to an actor, we will let the program wait for the reply before continuing with the program. We do this to ensure that all the quotes are added before we request one to be printed. We also want to print ...

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