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 ...

Get Introduction to JVM Languages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.