8.2. Hello World Using notify

For a simple example we are going to return to the “Hello World” application from Chapter 1. You will recall that we wrote a message entry into a space and then read it and printed its content, which happens to be the String “Hello World”. Now we are going to adapt that program to use the notify method instead of read.

To do so, our application will first register a listener that is interested in Message entries arriving in the space. Then, as in the original version, we will write a Message entry into the space. When the new entry arrives in the space, the space notifies the listener by calling the listener's notify method. The listener responds to the event by reading the Message entry from the space and printing ...

Get JavaSpaces™ Principles, Patterns, and Practice 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.